diff --git a/.vs/Crunchyroll Downloader/v17/.suo b/.vs/Crunchyroll Downloader/v17/.suo index 37ffb1e..2c4ddfc 100644 Binary files a/.vs/Crunchyroll Downloader/v17/.suo and b/.vs/Crunchyroll Downloader/v17/.suo differ diff --git a/Crunchyroll Downloader/Anime_Add.Designer.vb b/Crunchyroll Downloader/Anime_Add.Designer.vb index e59f4b3..e6ab8e2 100644 --- a/Crunchyroll Downloader/Anime_Add.Designer.vb +++ b/Crunchyroll Downloader/Anime_Add.Designer.vb @@ -328,6 +328,7 @@ Partial Class Anime_Add ' Me.btn_dl.BackgroundImage = Global.Crunchyroll_Downloader.My.Resources.Resources.main_button_download_default Me.btn_dl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch + Me.btn_dl.Cursor = System.Windows.Forms.Cursors.No Me.btn_dl.FlatAppearance.BorderSize = 0 Me.btn_dl.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.btn_dl.Font = New System.Drawing.Font("Microsoft Sans Serif", 27.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) diff --git a/Crunchyroll Downloader/Anime_Add.vb b/Crunchyroll Downloader/Anime_Add.vb index fecb4b7..036e658 100644 --- a/Crunchyroll Downloader/Anime_Add.vb +++ b/Crunchyroll Downloader/Anime_Add.vb @@ -11,6 +11,8 @@ Imports System.Text Imports System.Runtime.InteropServices.ComTypes Imports System.Windows.Forms.VisualStyles.VisualStyleElement.Status Imports Newtonsoft.Json.Linq +Imports System.Timers +Imports System.Security.Policy Public Class Anime_Add Public Mass_DL_Cancel As Boolean = False @@ -48,6 +50,16 @@ Public Class Anime_Add Btn_Close.Image = Main.CloseImg Btn_min.Image = Main.MinImg + btn_dl.Cursor = Cursors.No + btn_dl.BackgroundImage = My.Resources.main_button_download_deactivate + + If File.Exists("cookies.txt") = True Or Main.BowserWasOpen = True Then + btn_dl.BackgroundImage = My.Resources.main_button_download_default + btn_dl.Cursor = Cursors.Default + End If + + + Try Me.Icon = My.Resources.icon Catch ex As Exception @@ -147,6 +159,10 @@ Public Class Anime_Add Private Sub Btn_dl_Click(sender As Object, e As EventArgs) Handles btn_dl.Click + If btn_dl.Cursor = Cursors.No Then + Exit Sub + End If + Main.LoginOnly = "Download Mode!" 'MsgBox(Main.WebbrowserURL) @@ -154,7 +170,7 @@ Public Class Anime_Add If groupBox1.Visible = True Then ' Main.LoadedUrls.Clear() - Try + Try If CBool(InStr(textBox1.Text, "crunchyroll.com")) Or CBool(InStr(textBox1.Text, "funimation.com")) Then @@ -202,7 +218,15 @@ Public Class Anime_Add Debug.WriteLine("error- getting v1Json data for the bypass") Debug.WriteLine(ex.ToString) End Try - + ElseIf CBool(InStr(textBox1.Text, "funimation.com/shows/")) Then + Main.LoadingUrl = textBox1.Text + Main.LoadedUrls.Clear() + Main.b = False + Debug.WriteLine("loading funimation show url: " + Date.Now.ToString) + StatusLabel.Text = "Status: loading funimation...." + 'Main.LoadBrowser() + Browser.WebView2.CoreWebView2.Navigate(textBox1.Text) + Exit Sub End If End If @@ -228,8 +252,8 @@ Public Class Anime_Add End If Catch ex As Exception MsgBox(ex.ToString) - Main.b = True - MsgBox(Main.URL_Invaild, MsgBoxStyle.OkOnly) + Main.b = True + MsgBox(Main.URL_Invaild, MsgBoxStyle.OkOnly) End Try ElseIf groupBox2.Visible = True Then @@ -324,6 +348,11 @@ Public Class Anime_Add Private Sub Btn_dl_MouseEnter(sender As Object, e As EventArgs) Handles btn_dl.MouseEnter + If btn_dl.Cursor = Cursors.No Then + Exit Sub + End If + + If Mass_DL_Cancel = True Then btn_dl.Text = "Cancel" btn_dl.BackgroundImage = My.Resources.main_button_download_hovert @@ -339,6 +368,11 @@ Public Class Anime_Add End Sub Private Sub Btn_dl_MouseLeave(sender As Object, e As EventArgs) Handles btn_dl.MouseLeave + If btn_dl.Cursor = Cursors.No Then + Exit Sub + End If + + If Mass_DL_Cancel = True Then btn_dl.Text = "Cancel" btn_dl.BackgroundImage = My.Resources.main_button_download_hovert diff --git a/Crunchyroll Downloader/Browser.vb b/Crunchyroll Downloader/Browser.vb index ba0d67f..0c885de 100644 --- a/Crunchyroll Downloader/Browser.vb +++ b/Crunchyroll Downloader/Browser.vb @@ -21,24 +21,28 @@ Public Class Browser WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.crunchyroll.com/*", CoreWebView2WebResourceContext.All) WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.funimation.com/*", CoreWebView2WebResourceContext.All) - 'WebView2.CoreWebView2.AddWebResourceRequestedFilter("https://www.crunchyroll.com/*", CoreWebView2WebResourceContext.All) - 'WebView2.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All) AddHandler WebView2.CoreWebView2.WebResourceResponseReceived, AddressOf ObserveResponse - AddHandler WebView2.CoreWebView2.WebResourceRequested, AddressOf ObserveHttp 'WebView2.CoreWebView2.Settings.UserAgent = My.Settings.User_Agend.Replace(Chr(34), "").Replace("User-Agent: ", "") + ' + 'WebView2.CoreWebView2.Settings.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko" My.Settings.User_Agend = Chr(34) + "User-Agent: " + WebView2.CoreWebView2.Settings.UserAgent + Chr(34) 'MsgBox(My.Settings.User_Agend) + If WebView2.CoreWebView2.Source = "about:blank" Or WebView2.CoreWebView2.Source = Nothing Then 'TextBox1.Text = Main.Startseite WebView2.CoreWebView2.Navigate(Main.Startseite) + End If + + End Sub + Private Sub WebView2_SourceChanged(sender As Object, e As CoreWebView2SourceChangedEventArgs) Handles WebView2.SourceChanged Try TextBox1.Text = WebView2.CoreWebView2.Source @@ -54,6 +58,8 @@ Public Class Browser ' Dim HTML As String = WebView2.CoreWebView2. 'TextBox1.Text = WebView2.CoreWebView2.Source ' Exit Sub + + If e.HttpStatusCode = 200 Then Dim DocumentTitle As String = WebView2.CoreWebView2.DocumentTitle @@ -66,6 +72,13 @@ Public Class Browser GetCookies(Main.WebbrowserURL) + Main.BowserWasOpen = True + + If Application.OpenForms().OfType(Of Anime_Add).Any = True Then + Anime_Add.btn_dl.Cursor = Cursors.Default + Anime_Add.btn_dl.BackgroundImage = My.Resources.main_button_download_default + End If + End If End Sub @@ -78,6 +91,7 @@ Public Class Browser Private Sub Browser_Load(sender As Object, e As EventArgs) Handles Me.Load + Main.waveOutSetVolume(0, 0) If Me.Width > My.Computer.Screen.Bounds.Width Then Me.Width = My.Computer.Screen.Bounds.Width @@ -108,6 +122,8 @@ Public Class Browser End Sub Private Sub Browser_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing + Main.BowserWasOpen = False + 'Main.UserBowser = False 'Me.Location = New Point(-10000, -10000) 'Main.LoadingUrl = "" @@ -121,10 +137,12 @@ Public Class Browser End Sub + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 'MsgBox(Main.CR_etp_rt) 'MsgBox(Main.CR_ajs_user_id) 'MsgBox(Main.CheckCRLogin.ToString) + Try My.Computer.Clipboard.SetText(WebView2.CoreWebView2.Source) MsgBox("copied: " + Chr(34) + WebView2.CoreWebView2.Source + Chr(34)) @@ -152,8 +170,6 @@ Public Class Browser Private Async Sub ObserveResponse(ByVal sender As Object, ByVal e As CoreWebView2WebResourceResponseReceivedEventArgs) - - If CBool(InStr(Main.LoadingUrl, "crunchyroll.com")) Then @@ -165,27 +181,35 @@ Public Class Browser Dim reader As New StreamReader(Content) ContentString = reader.ReadToEnd - Dim Loc_CR_Cookies = " -H " + Chr(34) + Main.CR_Cookies + Chr(34) - Dim Token() As String = ContentString.Split(New String() {Chr(34) + "access_token" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim Token2() As String = Token(1).Split(New String() {Chr(34) + "," + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim Auth As String = "Bearer " + Token2(0) Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + Auth + Chr(34) - Main.ProcessLoading(Main.LoadingUrl, Auth2, Loc_CR_Cookies) + Main.ProcessLoading(Main.LoadingUrl, Auth2, Loc_CR_Cookies, 0) Main.CR_v1Token = "" Exit Sub - - ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "seasons?preferred_audio_language=")) And CBool(InStr(Main.LoadingUrl, "/series/")) Then Debug.WriteLine("Crunchyroll-Season: " + e.Request.Uri) Main.LoadedUrls.Add(e.Request) Exit Sub + 'ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "content/v2/cms/objects/")) Then + ' Debug.WriteLine("Crunchyroll-objects added to cache: " + e.Request.Uri) + ' Main.LoadedUrls.Add(e.Request) + + ' Exit Sub + 'ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "seasons?preferred_audio_language=")) And CBool(InStr(Main.LoadingUrl, "/series/")) Then + ' Debug.WriteLine("Crunchyroll-objects added to cache: " + e.Request.Uri) + ' Main.LoadedUrls.Add(e.Request) + + ' Exit Sub End If + + ElseIf CBool(InStr(Main.LoadingUrl, "funimation.com")) Then If CBool(InStr(e.Request.Uri, "?deviceType=web")) Then 'Debug.WriteLine(e.Request.Uri) @@ -251,87 +275,40 @@ Public Class Browser Next End If - If CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "streams?")) Then - Dim Headers As New List(Of KeyValuePair(Of String, String)) - Headers.AddRange(e.Request.Headers.ToList) - For i As Integer = 0 To Headers.Count - If CBool(InStr(Headers.Item(i).Value, "Bearer")) Then - Main.CR_AuthToken = Headers.Item(i).Value - Debug.WriteLine("Auth-Bearer: " + Main.CR_AuthToken) - End If - Next + 'If CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "streams?")) Then + ' Dim Headers As New List(Of KeyValuePair(Of String, String)) + ' Headers.AddRange(e.Request.Headers.ToList) + ' For i As Integer = 0 To Headers.Count + ' If CBool(InStr(Headers.Item(i).Value, "Bearer")) Then + ' Main.CR_AuthToken = Headers.Item(i).Value + ' Debug.WriteLine("Auth-Bearer: " + Main.CR_AuthToken) + ' End If + ' Next + 'End If + + ' + ' + If CBool(InStr(e.Request.Uri, "9016.2bd48f1e07adf6596b2d.js")) = True Then ' + Debug.WriteLine(e.Request.Uri) + 'MsgBox("Found!") + e.Response = WebView2.CoreWebView2.Environment.CreateWebResourceResponse(StringToStream(File.ReadAllText(Application.StartupPath + "\WebInterface\9016.2bd48f1e07adf6596b2d.js"), Encoding.UTF8), 200, "Not found", "content-type: application/javascript") + + End If - Exit Sub - - If CBool(InStr(Main.LoadingUrl, "crunchyroll.com")) Then - - If CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "streams?")) Then - Debug.WriteLine("Crunchyroll-Single: " + e.Request.Uri) - 'Dim ContentString As String = Nothing - 'Dim Content As New MemoryStream - 'e.Response.Content.CopyTo(Content) - 'Content.Position = 0 - 'ContentString = Encoding.UTF8.GetString(Content.ToArray()) - 'MsgBox(ContentString) - Main.LoadedUrls.Add(e.Request) - 'Main.CR_VideoJson = New UrlJson(e.Request.Uri, e.Request.Content.ToString) - Exit Sub - ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "/objects/")) And CBool(InStr(e.Request.Uri, "/watch/")) Then - Debug.WriteLine(e.Request.Uri) - Main.LoadedUrls.Add(e.Request) - 'Main.CR_ObjectsJson = New UrlJson(e.Request.Uri, e.Request.Content.ToString) - Exit Sub - ElseIf CBool(InStr(e.Request.Uri, "crunchyroll.com/")) And CBool(InStr(e.Request.Uri, "seasons?preferred_audio_language=")) Then - Debug.WriteLine("Crunchyroll-Season: " + e.Request.Uri) - Main.LoadedUrls.Add(e.Request) - 'Main.CR_SeasonJson = New UrlJson(e.Request.Uri, e.Request.Content.ToString) - Exit Sub - End If - - - - - ElseIf CBool(InStr(Main.LoadingUrl, "funimation.com")) Then - If CBool(InStr(e.Request.Uri, "?deviceType=web")) Then - 'Debug.WriteLine(e.Request.Uri) - Dim parms As String() = e.Request.Uri.Split(New String() {"?deviceType="}, System.StringSplitOptions.RemoveEmptyEntries) - Main.FunimationDeviceRegion = "?deviceType=" + parms(1) - - End If - If CBool(InStr(e.Request.Uri, "https://title-api.prd.funimationsvc.com")) Then - Debug.WriteLine("Funimtaion: " + e.Request.Uri) - If (Me.InvokeRequired) Then - Me.Invoke(Sub() Main.LoadedUrls.Add(e.Request)) - Exit Sub - Else - Main.LoadedUrls.Add(e.Request) - Exit Sub - End If - ElseIf CBool(InStr(e.Request.Uri, "/data/v2/shows/")) Then - Debug.WriteLine("Funimtaion: " + e.Request.Uri) - If (Me.InvokeRequired) Then - Me.Invoke(Sub() Main.LoadedUrls.Add(e.Request)) - Exit Sub - Else - Main.LoadedUrls.Add(e.Request) - Exit Sub - End If - ElseIf CBool(InStr(e.Request.Uri, "/data/v1/episodes/")) Then - Debug.WriteLine("Funimtaion: " + e.Request.Uri) - If (Me.InvokeRequired) Then - Me.Invoke(Sub() Main.LoadedUrls.Add(e.Request)) - Exit Sub - Else - Main.LoadedUrls.Add(e.Request) - Exit Sub - End If - End If - - End If End Sub + + Public Function StringToStream(input As String, enc As Encoding) As Stream + Dim memoryStream = New MemoryStream() + Dim streamWriter = New StreamWriter(memoryStream, enc) + streamWriter.Write(input) + streamWriter.Flush() + memoryStream.Position = 0 + Return memoryStream + End Function + Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick 'If Main.UserBowser = False Then ' WebView2.Reload() diff --git a/Crunchyroll Downloader/GetData.vb b/Crunchyroll Downloader/GetData.vb index 0b1ffd6..43cdc9e 100644 --- a/Crunchyroll Downloader/GetData.vb +++ b/Crunchyroll Downloader/GetData.vb @@ -7,6 +7,8 @@ Module GetData Public Function Curl(ByVal Url As String) As String + 'MsgBox(Url) + Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe") Dim startinfo As New System.Diagnostics.ProcessStartInfo Dim sr As StreamReader @@ -50,21 +52,16 @@ Module GetData Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish - If CurlOutput = Nothing And CurlError = Nothing Then - Debug.WriteLine("curl-E: " + "curl: ") - Return CurlError - ElseIf CurlOutput = Nothing And CurlError IsNot Nothing Then - Debug.WriteLine("curl-E: " + CurlError) - Return CurlError - ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then - Debug.WriteLine("curl-O: " + CurlOutput) - Return CurlOutput - ElseIf CurlOutput IsNot Nothing And CurlError IsNot Nothing Then - Debug.WriteLine("curl-O: " + CurlOutput) - Return CurlOutput + If CBool(InStr(CurlError, "curl")) Then + Debug.WriteLine(CurlError) + Throw New System.Exception("Error - Getting" + vbNewLine + CurlError) + Return Nothing + ElseIf CBool(InStr(CurlOutput, "curl")) Then + Debug.WriteLine(CurlOutput) + Throw New System.Exception("Error - Getting" + vbNewLine + CurlError) + Return Nothing Else - Debug.WriteLine("curl-E: " + "curl: ") - Return CurlError + Return CurlOutput End If @@ -118,28 +115,26 @@ Module GetData Loop Until Proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish - If CurlOutput = Nothing And CurlError = Nothing Then - Debug.WriteLine("CurlPost-E: " + "curl: ") - Return CurlError - ElseIf CurlOutput = Nothing And CurlError IsNot Nothing Then - Debug.WriteLine("CurlPost-E: " + CurlError) - Return CurlError - ElseIf CurlOutput IsNot Nothing And CurlError = Nothing Then - Debug.WriteLine("CurlPost-O: " + CurlOutput) - Return CurlOutput - ElseIf CurlOutput IsNot Nothing And CurlError IsNot Nothing Then - Debug.WriteLine("CurlPost-O: " + CurlOutput) - Return CurlOutput + If CBool(InStr(CurlError, "curl")) Then + Debug.WriteLine(CurlError) + Throw New System.Exception("Error - Getting" + vbNewLine + CurlError) + Return Nothing + ElseIf CBool(InStr(CurlOutput, "curl")) Then + Debug.WriteLine(CurlOutput) + Throw New System.Exception("Error - Getting" + vbNewLine + CurlError) + Return Nothing Else - Debug.WriteLine("CurlPost-E: " + "curl: ") - Return CurlError + Return CurlOutput End If End Function - Public Function CurlAuthNew(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String) As String + Public Function CurlAuthNew(ByVal Url As String, ByVal Cookies As String, ByVal Auth As String, Optional ByVal Test As Boolean = False) As String + If Test = True Then + Throw New System.Exception("Error - Getting" + vbNewLine + "Test") + End If Dim exepath As String = Path.Combine(Application.StartupPath, "lib", "curl.exe") @@ -190,10 +185,12 @@ Module GetData - If CurlOutput = Nothing Or CBool(InStr(CurlOutput, "curl")) Then - Throw New System.Exception("Error - Getting ObjectJson data" + vbNewLine + CurlOutput) + If CBool(InStr(CurlError, "curl")) Then + Debug.WriteLine(CurlError) + Throw New System.Exception("Error - Getting" + vbNewLine + CurlError) Return Nothing - ElseIf CBool(InStr(CurlError, "curl")) Then + ElseIf CBool(InStr(CurlOutput, "curl")) Then + Debug.WriteLine(CurlOutput) Throw New System.Exception("Error - Getting" + vbNewLine + CurlError) Return Nothing Else diff --git a/Crunchyroll Downloader/Main.vb b/Crunchyroll Downloader/Main.vb index 2a6e7a5..d104ad6 100644 --- a/Crunchyroll Downloader/Main.vb +++ b/Crunchyroll Downloader/Main.vb @@ -158,6 +158,7 @@ Public Class Main Public WebbrowserTitle As String = Nothing Public WebbrowserCookie As String = Nothing Public UserBowser As Boolean = False + Public BowserWasOpen As Boolean = False Public HybridMode As Boolean = False Public HardSubFunimation As String = "Disabled" Public Funimation_Bitrate As Integer = 0 @@ -438,6 +439,7 @@ Public Class Main Trace.Listeners.Add(tbtl) b = True Thread.CurrentThread.Name = "Main" + Debug.WriteLine("v" + Application.ProductVersion) Debug.WriteLine("Thread Name: " + Thread.CurrentThread.Name) @@ -980,12 +982,12 @@ Public Class Main End Sub - Public Sub GetCRVideoProxy(ByVal requesturl As String, ByVal AuthToken As String, ByVal WebsiteURL As String) - Dim Evaluator = New Thread(Sub() Me.GetCRVideo(requesturl, AuthToken, WebsiteURL)) + Public Sub GetCRVideoProxy(ByVal requesturl As String, ByVal AuthToken As String, ByVal WebsiteURL As String, ByVal RT_count As Integer) + Dim Evaluator = New Thread(Sub() Me.GetCRVideo(requesturl, AuthToken, WebsiteURL, RT_count)) Evaluator.Start() End Sub - Public Sub GetCRVideo(ByVal Streams As String, ByVal AuthToken As String, ByVal WebsiteURL As String) + Public Sub GetCRVideo(ByVal Streams As String, ByVal AuthToken As String, ByVal WebsiteURL As String, ByVal RT_count As Integer) If b = False Then b = True End If @@ -1204,6 +1206,8 @@ Public Class Main Dim VideoJObject As JObject = JObject.Parse(VideoJson) Dim VideoData As List(Of JToken) = VideoJObject.Children().ToList + Dim download_hls As CR_Beta_Stream = Nothing + For Each item As JProperty In VideoData item.CreateReader() Select Case item.Name @@ -1214,7 +1218,7 @@ Public Class Main For Each VideoSubItem As JProperty In VideoSubData Dim JsonEntryFormat As String = VideoSubItem.Name - If CBool(InStr(JsonEntryFormat, "drm")) Or CBool(InStr(JsonEntryFormat, "dash")) Or CBool(InStr(JsonEntryFormat, "download")) Or CBool(InStr(JsonEntryFormat, "urls")) Then ' + If CBool(InStr(JsonEntryFormat, "drm")) Or CBool(InStr(JsonEntryFormat, "dash")) Or CBool(InStr(JsonEntryFormat, "urls")) Then ' Or CBool(InStr(JsonEntryFormat, "download")) workaround http 502 / false http 400 Continue For End If @@ -1233,6 +1237,11 @@ Public Class Main SubLang = "" End If + If CBool(InStr(JsonEntryFormat, "download")) Then + download_hls = New CR_Beta_Stream(SubLang, JsonEntryFormat, Url) + Continue For + End If + CR_Streams.Add(New CR_Beta_Stream(SubLang, JsonEntryFormat, Url)) Next @@ -1240,6 +1249,9 @@ Public Class Main Next + If download_hls IsNot Nothing Then + CR_Streams.Add(download_hls) + End If Next Case "meta" 'each record is inside the entries array For Each MetaEntrys As JProperty In item.Values @@ -1469,22 +1481,22 @@ Public Class Main If CR_Chapters = True Then - - - Dim ChaptersUrl As String = "https://static.crunchyroll.com/datalab-intro-v2/" + CR_EpisodeID + ".json" Dim ChaptersJson As String = Nothing - - - ChaptersJson = Curl(ChaptersUrl) - - If CBool(InStr(ChaptersJson, "curl:")) = True Then + Dim ChaptersUrl As String = "https://static.crunchyroll.com/datalab-intro-v2/" + CR_EpisodeID + ".json" + Try ChaptersJson = Curl(ChaptersUrl) - End If - If CBool(InStr(ChaptersJson, "curl:")) = True Then - ChaptersJson = Nothing - Debug.WriteLine("no Chapter data... ignoring") - End If + If CBool(InStr(ChaptersJson, "curl:")) = True Then + ChaptersJson = Curl(ChaptersUrl) + End If + + If CBool(InStr(ChaptersJson, "curl:")) = True Then + ChaptersJson = Nothing + Debug.WriteLine("no Chapter data... ignoring") + End If + Catch ex As Exception + + End Try If ChaptersJson IsNot Nothing Then @@ -1642,16 +1654,28 @@ Public Class Main For i As Integer = 0 To CR_URI_Master.Count - 1 + Dim Count As String = (i + 1).ToString + Try + str = Curl(CR_URI_Master(i)) + If CBool(InStr(str, "curl:")) = False Then + Exit For + End If + Catch ex As Exception - str = Curl(CR_URI_Master(i)) - - If CBool(InStr(str, "curl:")) = False Then - Exit For - End If + Me.Invoke(New Action(Function() As Object + Anime_Add.StatusLabel.Text = "failed accessing master.m3u8 " + Count + "/" + CR_URI_Master.Count.ToString + Me.Text = "failed accessing master.m3u8 " + Count + "/" + CR_URI_Master.Count.ToString + Me.Invalidate() + Return Nothing + End Function)) + Debug.WriteLine("Error accessing master #" + i.ToString + " -- " + CR_URI_Master(i)) + Pause(5) + End Try Next - If CBool(InStr(str, "curl:")) = True Then + + If CBool(InStr(str, "curl:")) = True Or str = Nothing Then Debug.WriteLine("Checked " + CR_URI_Master.Count.ToString) MsgBox("Unable to get master.m3u8" + vbNewLine + str, MsgBoxStyle.Critical) @@ -1980,7 +2004,18 @@ Public Class Main ElseIf CBool(InStr(ex.ToString, Chr(34) + "UserAbort" + Chr(34))) Then MsgBox(ex.ToString, MsgBoxStyle.Information) ElseIf CBool(InStr(ex.ToString, "Error - Getting")) Then - Navigate(WebsiteURL) + If RT_count = 0 Then + If File.Exists("cookies.txt") = True Then + MsgBox("Request refused, try a new cookies.txt", MsgBoxStyle.Exclamation) + End If + Navigate(WebsiteURL) + Pause(5) + LoadBrowser(WebsiteURL, 1) + Exit Sub + End If + MsgBox(ex.ToString) + ' b = False + ' Navigate(WebsiteURL) Else MsgBox(ex.ToString, MsgBoxStyle.Information) End If @@ -2189,7 +2224,7 @@ Public Class Main End Sub Private Sub Btn_Browser_Click(sender As Object, e As EventArgs) Handles Btn_Browser.Click - Debug.WriteLine(Date.Now.ToString + "." + Date.Now.Millisecond.ToString) + 'Debug.WriteLine(Date.Now.ToString + "." + Date.Now.Millisecond.ToString) UserBowser = True If Application.OpenForms().OfType(Of Browser).Any = True Then @@ -2922,7 +2957,20 @@ Public Class Main Dim Funimation_m3u8_final As String = Nothing Dim client0 As New WebClient client0.Encoding = Encoding.UTF8 - If DownloadScope = 1 Then + If DownloadScope = DownloadScopeEnum.SubsOnly Then + + Me.Invoke(New Action(Function() As Object + Me.Text = "Status: Substitles only mode - skipped video" + Anime_Add.StatusLabel.Text = "Status: Substitles only mode - skipped video" + Me.Invalidate() + Return Nothing + End Function)) + + 'ElseIf DownloadScope = DownloadScopeEnum.MergeAudio Then + + + ElseIf DownloadScope = DownloadScopeEnum.OldDefault Or DownloadScope = DownloadScopeEnum.MergeAudio Or DownloadScope = DownloadScopeEnum.AudioOnly Then + For i As Integer = 0 To VideoStreams.Count - 1 If VideoStreams(i).Primary = True Then Funimation_m3u8_Primary = VideoStreams(i).Url @@ -2946,6 +2994,7 @@ Public Class Main Funimation_m3u8_MainVersion = Funimation_m3u8_Primary_Version FunimationDub = ConvertFunimationDub(ConvertJsonToFunimationDub(Funimation_m3u8_Primary_audioLanguage)) End If + If Funimation_m3u8_Main = Nothing Then If MessageBox.Show("No media matching your settings." + vbNewLine + "Avalible: Not implimentented, press 'Yes' to copy the data into the clipboard.", "No media", MessageBoxButtons.YesNo) = DialogResult.Yes Then Me.Invoke(New Action(Function() As Object @@ -3113,13 +3162,7 @@ Public Class Main End If Debug.WriteLine("Funimation_m3u8_final: " + Funimation_m3u8_final) Funimation_m3u8_final = Funimation_m3u8_final.Replace(Chr(34), "") - Else - Me.Invoke(New Action(Function() As Object - Me.Text = "Status: Substitles only mode - skipped video" - Anime_Add.StatusLabel.Text = "Status: Substitles only mode - skipped video" - Me.Invalidate() - Return Nothing - End Function)) + End If 'MsgBox(FunimationName3) Dim ResoHTMLDisplay As String = Reso.ToString + "p" @@ -3503,7 +3546,7 @@ Public Class Main End If Me.Text = "Status: Crunchyroll episode found." Debug.WriteLine("Crunchyroll episode found") - GetCRVideoProxy(Request.Uri, CR_AuthToken, WebbrowserURL) + GetCRVideoProxy(Request.Uri, CR_AuthToken, WebbrowserURL, 0) b = True LoadedUrls.Clear() Me.Text = "Crunchyroll Downloader" @@ -4033,6 +4076,8 @@ Public Class Main Return "text/html" ElseIf (httpRequest.EndsWith("txt")) Then Return "text/plain" + ElseIf (httpRequest.EndsWith("css")) Then + Return "text/css" ElseIf (httpRequest.EndsWith("gif")) Then Return "image/gif" ElseIf (httpRequest.EndsWith("jpg")) Then @@ -4294,7 +4339,7 @@ Public Class Main #Region "Process Urls" - Public Sub LoadBrowser(ByVal Url As String) + Public Sub LoadBrowser(ByVal Url As String, Optional ByVal RT_count As Integer = 0) LoadingUrl = Url @@ -4391,7 +4436,7 @@ Public Class Main End If - Debug.WriteLine("###" + CR_Cookies + "###") + 'Debug.WriteLine("###" + CR_Cookies + "###") Dim Loc_CR_Cookies = " -H " + Chr(34) + CR_Cookies + Chr(34) @@ -4448,14 +4493,14 @@ Public Class Main Dim Auth2 As String = " -H " + Chr(34) + "Authorization: " + CRBetaBearer + Chr(34) - ProcessLoading(Url, Auth2, Loc_CR_Cookies) + ProcessLoading(Url, Auth2, Loc_CR_Cookies, RT_count) Else 'to do End If End Sub - Public Sub ProcessLoading(ByVal url As String, Auth2 As String, ByVal Loc_CR_Cookies As String) + Public Sub ProcessLoading(ByVal url As String, Auth2 As String, ByVal Loc_CR_Cookies As String, ByVal RT_Count As Integer) If CBool(InStr(url, "crunchyroll.com")) = True And CBool(InStr(url, "series/")) = True Then @@ -4538,7 +4583,7 @@ Public Class Main Exit Sub End Try - GetCRVideoProxy(StreamsUrl, Auth2, url) + GetCRVideoProxy(StreamsUrl, Auth2, url, RT_Count) Else diff --git a/Crunchyroll Downloader/My Project/AssemblyInfo.vb b/Crunchyroll Downloader/My Project/AssemblyInfo.vb index df9933a..432f990 100644 --- a/Crunchyroll Downloader/My Project/AssemblyInfo.vb +++ b/Crunchyroll Downloader/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + +