-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [追加]DMSのストリームに対応 * [追加]新サーバーに対応 * [追加]ストリーム長を記録 * [追加]初期化ファイルのDL機能を追加 * [追加]再生機能を追加 * [変更]視聴APIのffmpegとの互換性の問題を修正 * [変更]DMS動画をアプリで開く機能を追加 * [変更]denoに移行 * [追加]視聴用のAPIを追加 * [追加]視聴ページ・NG機能のバックグラウンドを実装 * [変更]NGAPIの不具合を修正 * [追加]NG機能を追加 * [変更]動画再生機能の不具合を修正 * [追加]下部のパネルをBlazorに移行 * [追加]DL後のファイル処理機能を追加 * [変更]不要なファイルを削除 * [変更]セッション管理を集約 * [変更]ログアウト時に保存したCookieを削除するように変更
- Loading branch information
Showing
460 changed files
with
75,708 additions
and
21,380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
@startuml | ||
hide empty members | ||
|
||
title Cookieローカル保管システム | ||
|
||
|
||
interface ICookieInfo | ||
class CookieInfo | ||
interface ICookieStore | ||
class CookieDBHAndler | ||
interface IAttemptResult | ||
interface INiconicoCookieManager | ||
class NiconicoCookieManager | ||
class WebViewBehavior | ||
|
||
interface IWebview2SharedLogin | ||
interface ICoreWebview2Handler | ||
|
||
class V | ||
class VM | ||
|
||
interface ICookieInfo { | ||
+string UserSession | ||
+string UserSessionSecure | ||
+Task<bool> CheckCookie() | ||
} | ||
|
||
interface ICookieStore { | ||
+IAttemptResult<ICookieInfo> GetCookieInfo(); | ||
+IAttemptResult DeleteCookieInfo(); | ||
+IAttemptResult Update(ICookieInfo cookie); | ||
} | ||
|
||
interface INiconicoCookieManager { | ||
+void Wire(ICoreWebview2Handler handler) | ||
+void UnWire() | ||
+void HandleNavigate() | ||
+bool IsLoggedIn() | ||
} | ||
|
||
class NiconicoCookieManager { | ||
-ICoreWebview2Handler handler | ||
} | ||
|
||
ICookieInfo <|.. CookieInfo | ||
ICookieStore <|.. CookieDBHAndler | ||
INiconicoCookieManager <|.. NiconicoCookieManager | ||
ICookieStore o-- ICookieInfo | ||
ICookieStore <.. INiconicoCookieManager | ||
|
||
ICookieStore <.. IWebview2SharedLogin | ||
V *-- WebViewBehavior | ||
INiconicoCookieManager <.. WebViewBehavior | ||
|
||
|
||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Niconicome.Extensions.System; | ||
using Niconicome.Models.Domain.Local.Handlers; | ||
using Niconicome.Models.Domain.Local.Store.V2; | ||
using Niconicome.Models.Domain.Niconico; | ||
using Niconicome.Models.Domain.Niconico.UserAuth; | ||
using Niconicome.Models.Helper.Result; | ||
|
||
namespace Niconicome.Models.Auth.Cookie | ||
{ | ||
interface INiconicoCookieManager | ||
{ | ||
/// <summary> | ||
/// Webviewをハンドリングする | ||
/// </summary> | ||
/// <param name="handler"></param> | ||
void Wire(ICoreWebview2Handler handler); | ||
|
||
/// <summary> | ||
/// WebViewのハンドリングを解除する | ||
/// </summary> | ||
void UnWire(); | ||
|
||
/// <summary> | ||
/// URL遷移をハンドリングする | ||
/// </summary> | ||
Task<bool> HandleNavigate(); | ||
|
||
/// <summary> | ||
/// ログイン状態を確認する | ||
/// </summary> | ||
/// <returns></returns> | ||
Task<bool> IsLoggedIn(); | ||
|
||
} | ||
|
||
public class NiconicoCookieManager : INiconicoCookieManager | ||
{ | ||
#region field | ||
|
||
private ICoreWebview2Handler? handler; | ||
|
||
private readonly INiconicoContext _context; | ||
|
||
private readonly IStoredCookieLogin _storedCookieLogin; | ||
|
||
#endregion | ||
|
||
public NiconicoCookieManager(INiconicoContext context,IStoredCookieLogin storedCookieLogin) | ||
{ | ||
this._context = context; | ||
this._storedCookieLogin = storedCookieLogin; | ||
} | ||
|
||
#region Method | ||
|
||
public void Wire(ICoreWebview2Handler handler) | ||
{ | ||
this.handler = handler; | ||
} | ||
|
||
public void UnWire() | ||
{ | ||
this.handler = null; | ||
} | ||
|
||
public async Task<bool> HandleNavigate() | ||
{ | ||
if (this.handler is null) return false; | ||
|
||
var cookies = await this.handler.GetCookiesAsync(@"https://nicovideo.jp"); | ||
|
||
string userSession = string.Empty; | ||
string userSessionSecure = string.Empty; | ||
|
||
foreach (var cookie in cookies) | ||
{ | ||
if (cookie.Name == "user_session") | ||
{ | ||
userSession = cookie.Value; | ||
} | ||
else if (cookie.Name == "user_session_secure") | ||
{ | ||
userSessionSecure = cookie.Value; | ||
} | ||
} | ||
|
||
if (userSession.IsNullOrEmpty() || userSessionSecure.IsNullOrEmpty()) return false; | ||
|
||
var result = await this._context.LoginAndSaveCookieAsync(userSession, userSessionSecure); | ||
|
||
return result.IsSucceeded; | ||
} | ||
|
||
public async Task<bool> IsLoggedIn() | ||
{ | ||
return this._storedCookieLogin.CanLogin() && await this._storedCookieLogin.TryLogin(); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Niconicome.Models.Domain.Utils.Error; | ||
|
||
namespace Niconicome.Models.Auth.Error | ||
{ | ||
public enum ChromeSharedLoginError | ||
{ | ||
[ErrorEnum(ErrorLevel.Error, "Google Chromeからのクッキーの取得に失敗しました。")] | ||
FailedToGetCookie, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.