From 8a36bf5e6a00b6057d3094acdccdfdc06884f4d8 Mon Sep 17 00:00:00 2001 From: hama3254 <52826614+hama3254@users.noreply.github.com> Date: Tue, 9 Apr 2024 21:15:21 +0200 Subject: [PATCH] removed old video api, merged music/concert to anime function removed old video api - using new api for subtitles merged music/concert to anime function #926 --- .vs/Crunchyroll Downloader/v17/.suo | Bin 223232 -> 226816 bytes Crunchyroll Downloader/CRD-Classes.vb | 8 +- Crunchyroll Downloader/Main.vb | 981 ++---------------- .../My Project/AssemblyInfo.vb | 4 +- 4 files changed, 104 insertions(+), 889 deletions(-) diff --git a/.vs/Crunchyroll Downloader/v17/.suo b/.vs/Crunchyroll Downloader/v17/.suo index 57542d7ded55f96adfe42420de1646544621851d..a52e273adc70b225df0cd95dae6b3cbbbbfddea3 100644 GIT binary patch delta 6482 zcmd6r4OrAwzQ^bHn?X$|V1CeHpcO%Ueo5H!U+4yWZ|T*5kUSZCc6w9vI0@*K7OibD#U?`S3e$ z|MT)Y-*f)wjJ+Yi{&m30)UL~QI-M`L)zs7kqtkr z_m#6$jSQ=p#|!AHxXw1(B1-i+dh*waOFFpcW1%BI-(eyCvK+qj|M%bkw5p)JwAQg-S;UE}v14F>mAP)q9F<=7d3(`Rs zpa$>=>I?@aoed2j@dU7g$-oCZ4$MFmR?lLD9|H418!#HE^dYDu7U6L~dF@fycrXaG z2Ud^^rhq;utIFgf{Dg`FtqT%U5I6`_h0|bv;|>2_&2e?Hf9!Z9yy#6-g^qi}=)5k+ z8~y-RX~7yX=Bo$Ng6&Q%s9Mz%f?8A`BfYgQgHMV->D2$-+h!})1~2s z2yicH7?6H1Whm$Vv&v8%QcsIA;JlwpL(SMv(zsh0>g6DmQOd9a^g@9LQAS<6Ofr1TI-MBO-cGl~`|bPP zmDIszQ0q)Ktf6RZ76zZ@eaAh|_&RNk>d5Y>;Pd1N&k)Br-dz%2MYi7FUaE3Syx~IF zkzgh01YQ9ue*|nG7z)(L)YB7T2Y3^#0;_=&NU#R11?#|iumNl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qg9`5C=45SDM)e6rl5CxV&Qx`*TRGHR`pdN_AfyVikv^48c(ye&3_*cN;FB$>}u zIODgR%s~dt5JBTvEx(#~H`lE(#Fks^48C^Fn^YF{-6^)~hE3+G?Q8d>PyEy1!S?J& z-U)l}5Bv9y$r(ImL*}KDs*m>W7RUT3sXC5KnyCw!6xE)F)e^`$kc!2jm6TY$mh|GC z#nfBGEujqWwznqi?3J5O;#i>LkYZt{2+_7p3-1 z>6P4)vNPt0QHh)?jA*4BDn$$u_TC)!AB^5+Ph_$VVuU{xE45x=G-EOxtRBerwnlq8 zdQ2M6+472`mzO7#F!hDan8tS1SYvD%B<|KvLq8JMFjc3s-C1eu!$xlG#|xwr z6ef;laG7QrCnIY#VtVH-t*Aejm^Yc)JZ!yU3DXmN%kYv{&u(v>zfib&XopV@jlFUx z!}IA^&OA4@`px6#)4#OboUb+y=oHuyFQEKtU&FU6QxV3I@Z=$;$kGSvgJ{{Mh>(5j z7Eal-v!)^R{;zwz_U^_lleEZT9EXiUPZ6?{2a0!x^I%~dk4L}VH>1omV}}y_RDBZv zZ>YcONCP*FIA7mLxX z82+EnwD`aGd-F(+O-}3H@^e2nIX$a1b82ZxVn#}7T4H)?YH?y#T4_e&l$4SwnSG|F z_vw>d?4?^QiYs`s7%-b>YOC{knVuXXB@dRo(L7V^&Eq7IoX39@!H@9;S|K|h6Z=N< z4UG!dwet(E+^Xg8sq z^GKsW#o;6NETjyvzMjK{U9eGmv4H20^&qn-uH=r=mM+#GW)E$|M1G5`AK_>$1?msxLM6UL0@I{75$Xr=gm zEwAK+RQDwJ-!@6pQO*;`mhnE(bt82VLAgq<`0gb8i5lXX%b%vsE%vWL*F`Ja8e*#>!M4A8q diff --git a/Crunchyroll Downloader/CRD-Classes.vb b/Crunchyroll Downloader/CRD-Classes.vb index 08397e3..cf37486 100644 --- a/Crunchyroll Downloader/CRD-Classes.vb +++ b/Crunchyroll Downloader/CRD-Classes.vb @@ -87,15 +87,15 @@ End Class Public Class CR_MediaVersion Public AudioLang As String - Public media_guid As String + Public guid As String - Public Sub New(ByVal AudioLang As String, ByVal media_guid As String) + Public Sub New(ByVal AudioLang As String, ByVal guid As String) Me.AudioLang = AudioLang - Me.media_guid = media_guid + Me.guid = guid End Sub 'Me.audioLanguage, Public Overrides Function ToString() As String - Return String.Format("{0}, {1}", Me.AudioLang, Me.media_guid) + Return String.Format("{0}, {1}", Me.AudioLang, Me.guid) End Function End Class diff --git a/Crunchyroll Downloader/Main.vb b/Crunchyroll Downloader/Main.vb index a1de6ff..9512266 100644 --- a/Crunchyroll Downloader/Main.vb +++ b/Crunchyroll Downloader/Main.vb @@ -1,26 +1,23 @@ Option Strict On + Imports System.Net Imports System.Text Imports System.IO -Imports Microsoft.Win32 Imports System.Threading Imports System.Net.WebUtility Imports System.Net.Sockets Imports MetroFramework.Forms Imports MetroFramework Imports MetroFramework.Components -Imports System.Globalization Imports System.ComponentModel Imports Newtonsoft.Json.Linq Imports System.Runtime.InteropServices -Imports System.Security.Policy Imports MyProvider.MyProvider -Imports System.Windows Imports Microsoft.Web.WebView2.Core -Imports System.Net.Http Imports Crunchyroll_Downloader.CRD_Classes + Public Class Main Inherits MetroForm @@ -986,28 +983,18 @@ Public Class Main End Sub Public Sub GetCRVideoProxy(ByVal requesturl As String, ByVal AuthToken As String, ByVal WebsiteURL As String, ByVal RT_count As Integer) - - If CBool(InStr(WebsiteURL, "musicvideo")) = True Or CBool(InStr(WebsiteURL, "/concert/")) = True Then - Dim Evaluator = New Thread(Sub() Me.GetCRMusik(requesturl, AuthToken, WebsiteURL, RT_count)) - Evaluator.Start() - Else - Dim Evaluator = New Thread(Sub() Me.GetCRVideo(requesturl, AuthToken, WebsiteURL, RT_count)) - Evaluator.Start() - End If 'outsourcing - - + Dim Evaluator = New Thread(Sub() Me.GetCRVideo(requesturl, AuthToken, WebsiteURL, RT_count)) + Evaluator.Start() End Sub -#Region "Musik" - Public Sub GetCRMusik(ByVal Streams As String, ByVal AuthToken As String, ByVal WebsiteURL As String, ByVal RT_count As Integer) + + + 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 - 'Debug.WriteLine(Streams) - 'Debug.WriteLine(vbCrLf) + Debug.WriteLine("Website: " + WebsiteURL) - - Try Grapp_RDY = False Dim ffmpeg_command_temp As String = ffmpeg_command @@ -1020,12 +1007,13 @@ Public Class Main Dim CR_episode_duration_ms As String = "60000000" Dim CR_episode2 As String = Nothing Dim CR_Anime_Staffel_int As String = Nothing + Dim CR_episode_int As String = Nothing Dim CR_title As String = Nothing - Dim CR_audio_locale As String = Nothing + Dim CR_audio_locale As String = "ja-JP" Dim CR_audio_isDubbed As Boolean = False Dim ResoUsed As String = "x" + Reso.ToString Dim ffmpegInput As String = "-i [Subtitles only]" - + Dim CR_HardSubLang As String = SubSprache.CR_Value Dim Pfad2 As String Dim TextBox2_Text As String = Nothing @@ -1047,13 +1035,27 @@ Public Class Main Dim CR_EpisodeID As String = "" + #Region "No anime :(" + Dim NewAPI_0 As String() = WebsiteURL.Split(New String() {"watch/"}, System.StringSplitOptions.RemoveEmptyEntries) + Dim NewAPI_1 As String() = NewAPI_0(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries) + + Dim page_guid As String = NewAPI_1(0) If CBool(InStr(WebsiteURL, "musicvideo")) = True Then 'TextBox2_Text to bypasss name for now - Dim ObjectsURL As String = Streams.Replace("music/", "music/music_videos/").Replace("/streams", "") + + + Dim page_guid_0 As String() = WebsiteURL.Split(New String() {"watch/musicvideo/"}, System.StringSplitOptions.RemoveEmptyEntries) + Dim page_guid_1 As String() = page_guid_0(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries) + + + + Dim ObjectsURL As String = "https://www.crunchyroll.com/content/v2/music/music_videos/" + page_guid_1(0) 'Streams.Replace("music/", "music/music_videos/").Replace("/streams", "") + + page_guid = "music/" + page_guid_1(0) ObjectJson = CurlAuthNew(ObjectsURL, Loc_CR_Cookies, Loc_AuthToken) @@ -1067,7 +1069,12 @@ Public Class Main ElseIf CBool(InStr(WebsiteURL, "/concert/")) = True Then - Dim ObjectsURL As String = Streams.Replace("music/", "music/concerts/").Replace("/streams", "") + Dim page_guid_0 As String() = WebsiteURL.Split(New String() {"watch/concert/"}, System.StringSplitOptions.RemoveEmptyEntries) + Dim page_guid_1 As String() = page_guid_0(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries) + + Dim ObjectsURL As String = "https://www.crunchyroll.com/content/v2/music/concerts/" + page_guid_1(0) 'Streams.Replace("music/", "music/music_videos/").Replace("/streams", "") + + page_guid = "music/" + page_guid_1(0) ObjectJson = CurlAuthNew(ObjectsURL, Loc_CR_Cookies, Loc_AuthToken) @@ -1089,651 +1096,9 @@ Public Class Main Else ' Not needed for Music or concerts - End If -#Region "VideoJson" - Dim VideoJson As String = Nothing - VideoJson = CurlAuthNew(Streams, Loc_CR_Cookies, Loc_AuthToken) - - - Debug.WriteLine("VideoJson: " + VideoJson) - Debug.WriteLine("VideoStreams: " + Streams) - - - Dim CR_HardSubLang As String = SubSprache.CR_Value - VideoJson = CleanJSON(VideoJson) - - 'MsgBox(VideoJson) -#End Region - - - -#Region "m3u8 suche" - - - - - 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 - Case "data" 'each record is inside the entries array - For Each Entry As JObject In item.Values - - Dim VideoSubData As List(Of JToken) = Entry.Children().ToList - 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, "urls")) Then ' Or CBool(InStr(JsonEntryFormat, "download")) workaround http 502 / false http 400 - Continue For - End If - - Dim SubData As List(Of JToken) = VideoSubItem.Children().ToList - For Each SubItem As JObject In SubData - SubItem.CreateReader() - - Dim StreamFormats As List(Of JToken) = SubItem.Children().ToList - - - For Each HardsubStreams As JProperty In StreamFormats - HardsubStreams.CreateReader() - Dim SubLang As String = HardsubStreams.Name - Dim Url As String = HardsubStreams.Value("url").ToString - If SubLang = Nothing Or SubLang = "" Then - 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 - Next - - - 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 - Select Case MetaEntrys.Name - Case "audio_locale" - If CR_audio_isDubbed = True Then - Dim AudioTag As String = MetaEntrys.Value.ToString - CR_audio_locale = String.Join(" ", AudioTag.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c).Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") - Else - CR_audio_locale = "ja-JP" - End If - - End Select - - Next - - End Select - Next - - Dim CR_URI_Master As New List(Of String) - - - Dim RawStream As New List(Of String) - - - - For c As Integer = 0 To CR_Streams.Count - 1 - Dim i As Integer = c - 'Debug.WriteLine("1457: " + i.ToString + "/" + CR_Streams.Count.ToString + " " + CR_Streams.Item(i).subLang + " " + CR_Streams.Item(i).Format) - If CR_Streams.Item(i).subLang = CR_HardSubLang Then - CR_URI_Master.Add(CR_Streams.Item(i).Url) - 'Debug.WriteLine("CR_HardSubLang-" + CR_HardSubLang + "--" + CR_Streams.Item(i).Url) - ElseIf CR_Streams.Item(i).subLang = "" And CR_HardSubLang = "null" Then - CR_URI_Master.Add(CR_Streams.Item(i).Url) - 'Debug.WriteLine("CR_HardSubLang-null" + CR_HardSubLang + "--" + CR_Streams.Item(i).Url) - ElseIf CR_Streams.Item(i).subLang = "" And CR_audio_locale IsNot "ja-JP" And DubMode = True Then 'nothing/raw - RawStream.Add(CR_Streams.Item(i).Url) - End If - Next - - If CR_URI_Master.Count = 0 And RawStream.Count > 0 Then - CR_URI_Master.Clear() - CR_URI_Master.AddRange(RawStream) - - ElseIf CR_URI_Master.Count = 0 Then - Me.Invoke(New Action(Function() As Object - ResoNotFoundString = VideoJson - DialogTaskString = "Language_CR_Beta" - ErrorDialog.ShowDialog() - Return Nothing - End Function)) - If UserCloseDialog = True Then - Throw New System.Exception(Chr(34) + "UserAbort" + Chr(34)) - Else - 'MsgBox(CR_HardSubLang) - CR_HardSubLang = ResoBackString - ResoBackString = Nothing - 'MsgBox(CR_Streams.Count.ToString) - For i As Integer = 0 To CR_Streams.Count - 1 - Debug.WriteLine("1571: " + CR_Streams.Item(i).subLang) - If CR_Streams.Item(i).subLang = CR_HardSubLang Then - CR_URI_Master.Add(CR_Streams.Item(i).Url) - End If - - Next - - End If - End If - - 'MsgBox(CR_URI_Master.Count.ToString) - - If CBool(InStr(CR_URI_Master(0), "master.m3u8")) Then - Me.Invoke(New Action(Function() As Object - Anime_Add.StatusLabel.Text = "Status: m3u8 found, looking for resolution" - Me.Text = "Status: m3u8 found, looking for resolution" - Me.Invalidate() - Return Nothing - End Function)) - Else - If MessageBox.Show("The Url below failed a check, continue?" + vbNewLine + CR_URI_Master(0), "Mission failed?", MessageBoxButtons.OKCancel) = DialogResult.OK Then - - Else - Throw New System.Exception("Premium Episode") - End If - - End If - -#End Region - -#Region "Name" - - - - CR_FilenName = RemoveExtraSpaces(String.Join(" ", TextBox2_Text.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c)).Replace(Chr(34), "").Replace("\", "").Replace("/", "") 'System.Text.RegularExpressions.Regex.Replace(TextBox2_Text, "[^\w\\-]", " ")) - - - - Debug.WriteLine(CR_FilenName) - - CR_FilenName = String.Join(" ", CR_FilenName.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c).Replace(Chr(34), "").Replace("\", "").Replace("/", "") 'System.Text.RegularExpressions.Regex.Replace(CR_FilenName, "[^\w\\-]", " ") - CR_FilenName = RemoveExtraSpaces(CR_FilenName) - 'My.Computer.FileSystem.WriteAllText("log.log", WebbrowserText, False) - Pfad2 = UseSubfolder(CR_series_title, CR_FolderSeason, Pfad) - If Not Directory.Exists(Path.GetDirectoryName(Pfad2)) Then - ' Nein! Jetzt erstellen... - Try - Directory.CreateDirectory(Path.GetDirectoryName(Pfad2)) - Pfad2 = Chr(34) + Pfad2 + CR_FilenName + VideoFormat + Chr(34) - Catch ex As Exception - ' Ordner wurde nich erstellt - Pfad2 = Chr(34) + Pfad + "\" + CR_FilenName + VideoFormat + Chr(34) - Pfad2 = Pfad2.Replace("\\", "\") - End Try - Else - Pfad2 = Chr(34) + Pfad2 + CR_FilenName + VideoFormat + Chr(34) - End If -#End Region - - - -#Region "lösche doppel download" - 'MsgBox(Pfad2) - Dim Pfad5 As String = Pfad2.Replace(Chr(34), "") - Dim Pfad6 As String = Pfad5 - Dim MergeAudio As Boolean = False - - - If My.Computer.FileSystem.FileExists(Pfad5) Then - Me.Invoke(New Action(Function() As Object - Anime_Add.StatusLabel.Text = "Status: The file already exists." - Me.Text = "Status: The file already exists." - Me.Invalidate() - Return Nothing - End Function)) - If MessageBox.Show("The file " + Pfad5 + " already exists." + vbNewLine + "You want to override it?", "File exists!", MessageBoxButtons.OKCancel) = DialogResult.OK Then - Try - My.Computer.FileSystem.DeleteFile(Pfad5) - Catch ex As Exception - End Try - Else - Grapp_RDY = True - Exit Sub - End If - - End If -#End Region - - -#Region "GetResolution" - - If Reso = 42 And HybridMode = False Then - - ffmpegInput = "-i " + Chr(34) + CR_URI_Master(0) + Chr(34) - - ElseIf DownloadScope = DownloadScopeEnum.SubsOnly Then - ffmpegInput = "-i [Subtitles only]" - Else - - Dim str As String = Nothing - - - - - For i As Integer = 0 To CR_URI_Master.Count - 1 - 'MsgBox(CR_URI_Master(i)) - 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 - - 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 Or str = Nothing Then - - Debug.WriteLine("Checked " + CR_URI_Master.Count.ToString) - MsgBox("Unable to get master.m3u8" + vbNewLine + str, MsgBoxStyle.Critical) - Grapp_RDY = True - Exit Sub - - ElseIf DownloadScope = DownloadScopeEnum.AudioOnly Or MergeAudio = True Then - - If CBool(InStr(str, "x480,")) Then - ResoUsed = "x480" - ElseIf CBool(InStr(str, "x" + Reso.ToString + ",")) Then - ResoUsed = "x" + Reso.ToString - End If - - ElseIf CBool(InStr(str, "x" + Reso.ToString + ",")) Then - ResoUsed = "x" + Reso.ToString - Else - If CBool(InStr(str, ResoSave + ",")) Then - ResoUsed = ResoSave - Else - Me.Invoke(New Action(Function() As Object - DialogTaskString = "Resolution" - ResoNotFoundString = str - ErrorDialog.ShowDialog() - Return Nothing - End Function)) - If UserCloseDialog = True Then - Throw New System.Exception(Chr(34) + "UserAbort" + Chr(34)) - Else - ResoUsed = ResoBackString - ResoSave = ResoBackString - End If - End If - End If - - Dim ffmpeg_url_3 As String = Nothing - Dim LineChar As String = vbLf - If CBool(InStr(str, vbCrLf)) Then - LineChar = vbCrLf - ElseIf CBool(InStr(str, vbCr)) Then - LineChar = vbCr - End If - Dim ffmpeg_url_1 As String() = str.Split(New String() {LineChar}, System.StringSplitOptions.RemoveEmptyEntries) - - For i As Integer = 0 To ffmpeg_url_1.Count - 2 'Step 2 - If CBool(InStr(ffmpeg_url_1(i), ResoUsed + ",")) Then - ffmpeg_url_3 = ffmpeg_url_1(i + 1) - End If - Next - - ffmpegInput = "-i " + Chr(34) + ffmpeg_url_3.Trim() + Chr(34) - - End If - - - -#End Region - -#Region "GetSoftsubs" - Dim SoftSubsAvailable As New List(Of String) - Dim CCAvailable As New List(Of String) - - Dim SoftSubsList As New List(Of CR_Subtiles) - - - - - Dim SplitVideo As String() = VideoJson.Split(New String() {Chr(34) + "closed_captions" + Chr(34) + ":"}, System.StringSplitOptions.RemoveEmptyEntries) - - If SoftSubs.Count > 0 And My.Settings.Captions = True Then - For i As Integer = 0 To SoftSubs.Count - 1 - If CBool(InStr(SplitVideo(1), Chr(34) + "locale" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34))) Then - CCAvailable.Add(SoftSubs(i)) - End If - Next - End If - - If SoftSubs.Count > 0 And CCAvailable.Count = 0 Then - For i As Integer = 0 To SoftSubs.Count - 1 - If CBool(InStr(VideoJson, Chr(34) + "locale" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34))) Then - SoftSubsAvailable.Add(SoftSubs(i)) - End If - Next - ElseIf SoftSubs.Count > 0 And CCAvailable.Count > 0 Then - SoftSubsAvailable.AddRange(CCAvailable) - End If - - - If DownloadScope = DownloadScopeEnum.AudioOnly Then - - - ffmpegInput = ffmpegInput + " -metadata:s:a:0 language=" + ConvertSubValue(CR_audio_locale, ConvertSubsEnum.MP4CC_ISO_639_2) + " " + ffmpeg_command_temp - - ElseIf MergeAudio = True Then - - ffmpegInput = "-i " + Chr(34) + Pfad6 + Chr(34) + " " + ffmpegInput + " -map 0 -map 1:a" + " -metadata:s:a:" + FFMPEG_Audio(Pfad6).ToString + " language=" + ConvertSubValue(CR_audio_locale, ConvertSubsEnum.MP4CC_ISO_639_2) + " -c copy" - - - ElseIf SoftSubsAvailable.Count > 0 Or CCAvailable.Count > 0 Then - - Dim MergeSubsNow As Boolean = MergeSubs - - If DownloadScope = DownloadScopeEnum.SubsOnly Then - MergeSubsNow = False - End If - - Debug.WriteLine("Softsubs Default: " + DefaultSubCR) - - For i As Integer = 0 To SoftSubsAvailable.Count - 1 - - Dim SubsJson As String = VideoJson - If CCAvailable.Count > 0 Then - SubsJson = SplitVideo(1) - End If - - - Dim SoftSub As String() = SubsJson.Split(New String() {Chr(34) + "locale" + Chr(34) + ":" + Chr(34) + SoftSubsAvailable(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) - Dim SoftSub_2 As String() = SoftSub(1).Split(New [Char]() {Chr(34)}) - Dim SoftSub_3 As String = SoftSub_2(0).Replace("&", "&").Replace("/u0026", "&").Replace("\u002F", "/").Replace("\u0026", "&") - SoftSubsList.Add(New CR_Subtiles(SoftSubsAvailable(i), ConvertSubValue(SoftSubsAvailable(i), ConvertSubsEnum.DisplayText), " -i " + Chr(34) + SoftSub_3 + Chr(34), i.ToString, SoftSubsAvailable(i) = DefaultSubCR)) - - Next - - - If MergeSubsNow = True Then - Dim DispositionIndex As Integer = 69 - Dim SoftSubMergeURLs As String = "" - Dim SoftSubMergeMaps As String = " -map 0:v -map 0:a" - Dim SoftSubMergeMetatata As String = "" - Dim IndexMoveMap As Integer = 1 - If CR_MetadataUsage = True Then - IndexMoveMap = 2 - End If - - For i As Integer = 0 To SoftSubsList.Count - 1 - - SoftSubMergeURLs = SoftSubMergeURLs + " " + SoftSubsList(i).Url - SoftSubMergeMaps = SoftSubMergeMaps + " -map " + (i + IndexMoveMap).ToString - SoftSubMergeMetatata = SoftSubMergeMetatata + " -metadata:s:s:" + i.ToString + " language=" + ConvertSubValue(SoftSubsList(i).SubLangValue, ConvertSubsEnum.MP4CC_ISO_639_2) + " -metadata:s:s:" + i.ToString + " title=" + Chr(34) + SoftSubsList(i).SubLangName + Chr(34) + " -metadata:s:s:" + i.ToString + " handler_name=" + Chr(34) + SoftSubsList(i).SubLangName + Chr(34) - - If SoftSubsList(i).DefaultSub = True Then - DispositionIndex = i - End If - - Next - - Debug.WriteLine("-disposition:s: " + DispositionIndex.ToString) - - If DispositionIndex < 69 Then - SoftSubMergeMetatata = SoftSubMergeMetatata + " -disposition:s:" + DispositionIndex.ToString + " default" - End If - - - ffmpegInput = ffmpegInput + " " + SoftSubMergeURLs + SoftSubMergeMaps + " " + ffmpeg_command_temp + " -c:s " + MergeSubsFormat + SoftSubMergeMetatata + " -metadata:s:a:0 language=" + ConvertSubValue(CR_audio_locale, ConvertSubsEnum.MP4CC_ISO_639_2) - - - - Else - - For i As Integer = 0 To SoftSubsList.Count - 1 - Dim SubFormat As String = "ass" - If CCAvailable.Count > 0 Then - SubFormat = "vtt" - End If - Dim i2 As Integer = i - Me.Invoke(New Action(Function() As Object - Anime_Add.StatusLabel.Text = "Status: downloading subtitle file " + SoftSubsList(i2).SubLangName - Me.Text = "Status: downloading subtitle file " + SoftSubsList(i2).SubLangName - Me.Invalidate() - Return Nothing - End Function)) - - Dim SubText As String = "" - SubText = Curl(SoftSubsList(i2).Url.Replace(" -i ", "").Replace(Chr(34), "")) - If My.Settings.SubtitleMod1 = True Then - SubText = AddScaledBorderAndShadow(SubText) - End If - - Dim Pfad3 As String = Pfad2.Replace(Chr(34), "") - Dim FN As String = Path.ChangeExtension(Path.Combine(Path.GetFileNameWithoutExtension(Pfad3) + "." + ConvertSubValue(SoftSubsList(i2).SubLangValue, ConvertSubsEnum.DisplayText) + Path.GetExtension(Pfad3)), SubFormat) - If i = 0 And IncludeLangName = False Then - FN = Path.ChangeExtension(Path.GetFileName(Pfad3), SubFormat) - End If - Dim Pfad4 As String = Path.Combine(Path.GetDirectoryName(Pfad3), FN) - WriteText(Pfad4, SubText) - Pause(3) - - Next - - - ffmpegInput = ffmpegInput + " -metadata:s:a:0 language=" + ConvertSubValue(CR_audio_locale, ConvertSubsEnum.MP4CC_ISO_639_2) + " " + ffmpeg_command_temp 'ConvertSubValue(CR_audio_locale, ConvertSubsEnum.MP4CC_ISO_639_2) - - End If - Else - - - ffmpegInput = ffmpegInput + " -metadata:s:a:0 language=" + ConvertSubValue(CR_audio_locale, ConvertSubsEnum.MP4CC_ISO_639_2) + " " + ffmpeg_command_temp - - End If - - ffmpegInput = RemoveExtraSpaces(ffmpegInput) -#End Region - -#Region "thumbnail" - Dim thumbnail3 As String = "" - - Try - - Dim thumbnail As String() = ObjectJson.Split(New String() {"https://"}, System.StringSplitOptions.RemoveEmptyEntries) - For i As Integer = 0 To thumbnail.Count - 1 - If CBool(InStr(thumbnail(i), ".jpg" + Chr(34))) Then - Dim thumbnail2 As String() = thumbnail(i).Split(New String() {".jpg" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"}) - thumbnail3 = "https://" + thumbnail2(0).Replace("\/", "/") + ".jpg" - Exit For - ElseIf CBool(InStr(thumbnail(i), ".jpeg" + Chr(34))) Then - Dim thumbnail2 As String() = thumbnail(i).Split(New String() {".jpeg" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"}) - thumbnail3 = "https://" + thumbnail2(0).Replace("\/", "/") + ".jpeg" - Exit For - ElseIf CBool(InStr(thumbnail(i), ".jpe" + Chr(34))) Then - Dim thumbnail2 As String() = thumbnail(i).Split(New String() {".jpe" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"}) - thumbnail3 = "https://" + thumbnail2(0).Replace("\/", "/") + ".jpe" - Exit For - ElseIf CBool(InStr(thumbnail(i), ".JPEG" + Chr(34))) Then - Dim thumbnail2 As String() = thumbnail(i).Split(New String() {".JPEG" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"}) - thumbnail3 = "https://" + thumbnail2(0).Replace("\/", "/") + ".JPEG" - Exit For - ElseIf CBool(InStr(thumbnail(i), ".JPG" + Chr(34))) Then - Dim thumbnail2 As String() = thumbnail(i).Split(New String() {".JPG" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"}) - thumbnail3 = "https://" + thumbnail2(0).Replace("\/", "/") + ".JPG" - Exit For - ElseIf CBool(InStr(thumbnail(i), ".JPE" + Chr(34))) Then - Dim thumbnail2 As String() = thumbnail(i).Split(New String() {".JPE" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) '(New [Char]() {"-"}) - thumbnail3 = "https://" + thumbnail2(0).Replace("\/", "/") + ".JPE" - Exit For - End If - Next - - Catch ex As Exception - - End Try -#End Region - -#Region "item constructor" - -#Region "Display Hard_Softsubs" - Dim SubType_Value As String = Nothing - If Not CR_HardSubLang = "" Then - SubType_Value = "Hardsub: " + ConvertSubValue(CR_HardSubLang, ConvertSubsEnum.DisplayText) - End If - If SoftSubsList.Count > 0 And CR_HardSubLang = "" Then - SubType_Value = "Softsubs: " - For i As Integer = 0 To SoftSubsList.Count - 1 - SubType_Value = SubType_Value + SoftSubsList(i).SubLangName - If i < SoftSubsList.Count - 1 Then - SubType_Value = SubType_Value + ", " - End If - Next - End If -#End Region - - -#Region "Display Resolution" - - - Dim ResoHTMLDisplay As String = Nothing - Dim ResoHTML As String() = ResoUsed.Split(New String() {"x"}, System.StringSplitOptions.RemoveEmptyEntries) - If ResoHTML.Count > 1 Then - ResoHTMLDisplay = ResoHTML(1) + "p" - Else - ResoHTMLDisplay = ResoHTML(0) + "p" - End If - - Dim L2Name As String = String.Join(" ", CR_FilenName.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c) 'System.Text.RegularExpressions.Regex.Replace(CR_FilenName_Backup, "[^\w\\-]", " ") - - If Reso = 42 And HybridMode = False Then - ResoHTMLDisplay = "[Auto]" - End If -#End Region - - - Dim L1Name_Split As String() = WebsiteURL.Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries) - Dim L1Name As String = L1Name_Split(1).Replace("www.", "") + " | Dub : " + ConvertSubValue(CR_audio_locale, ConvertSubsEnum.DisplayText) - - 'MsgBox(URL_DL) - - - Me.Invoke(New Action(Function() As Object - ListItemAdd(Path.GetFileName(Pfad2.Replace(Chr(34), "")), L1Name, L2Name, ResoHTMLDisplay, SubType_Value, thumbnail3, ffmpegInput, Pfad2) - Return Nothing - End Function)) - 'liList.Add(My.Resources.htmlvorThumbnail + thumbnail3 + My.Resources.htmlnachTumbnail + CR_title + "
" + CR_season_number + " " + CR_episode + My.Resources.htmlvorAufloesung + ResoHTMLDisplay + My.Resources.htmlvorSoftSubs + vbNewLine + SubValuesToDisplay() + My.Resources.htmlvorHardSubs + Subsprache3 + My.Resources.htmlnachHardSubs + "") - 'Form1.RichTextBox1.Text = My.Resources.htmlvorThumbnail + thumbnail3 + My.Resources.htmlnachTumbnail + CR_Anime_Titel + "
" + CR_Anime_Staffel + " " + CR_Anime_Folge + My.Resources.htmlvorAufloesung + ResoHTMLDisplay + My.Resources.htmlvorSoftSubs + vbNewLine + SubValuesToDisplay() + My.Resources.htmlvorHardSubs + Subsprache3 + My.Resources.htmlnachHardSubs + "" -#End Region - Grapp_RDY = True - Me.Invoke(New Action(Function() As Object - Anime_Add.StatusLabel.Text = "Status: idle" - Me.Text = "Crunchyroll Downloader" - ResoBackString = Nothing - Me.Invalidate() - Return Nothing - End Function)) - - Catch ex As Exception - Me.Invoke(New Action(Function() As Object - Anime_Add.StatusLabel.Text = "Status: idle" - Me.Text = "Crunchyroll Downloader" - ResoBackString = Nothing - Me.Invalidate() - Return Nothing - End Function)) - Grapp_RDY = True - If CBool(InStr(ex.ToString, "Could not find the sub language")) Then - MsgBox(Sub_language_NotFound + SubSprache.DisplayText) - ElseIf CBool(InStr(ex.ToString, "RESOLUTION Not Found")) Then - MsgBox(Resolution_NotFound) - ElseIf CBool(InStr(ex.ToString, "Premium Episode")) Then - MsgBox(Premium_Stream, MsgBoxStyle.Information) - ElseIf CBool(InStr(ex.ToString, "System.UnauthorizedAccessException")) Then - MsgBox(ErrorNoPermisson + vbNewLine + ex.ToString, MsgBoxStyle.Information) - ElseIf CBool(InStr(ex.ToString, Chr(34) + "UserAbort" + Chr(34))) Then - MsgBox(ex.ToString, MsgBoxStyle.Information) - ElseIf CBool(InStr(ex.ToString, "Error - Getting")) Then - - MsgBox(ex.ToString) - - Else - MsgBox(ex.ToString, MsgBoxStyle.Information) - End If - End Try ' - End Sub -#End Region - 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 - 'Debug.WriteLine(Streams) - 'Debug.WriteLine(vbCrLf) - Debug.WriteLine("Website: " + WebsiteURL) - - - - Try - Grapp_RDY = False - Dim ffmpeg_command_temp As String = ffmpeg_command - Dim CR_MetadataUsage As Boolean = False - Dim CR_Streams As New List(Of CR_Beta_Stream) - Dim CR_series_title As String = Nothing - Dim CR_season_number As String = Nothing - Dim CR_FolderSeason As String = Nothing - Dim CR_episode As String = Nothing - Dim CR_episode_duration_ms As String = "60000000" - Dim CR_episode2 As String = Nothing - Dim CR_Anime_Staffel_int As String = Nothing - Dim CR_episode_int As String = Nothing - Dim CR_title As String = Nothing - Dim CR_audio_locale As String = "ja-JP" - Dim CR_audio_isDubbed As Boolean = False - Dim CR_Region As String = "DE" - Dim ResoUsed As String = "x" + Reso.ToString - Dim ffmpegInput As String = "-i [Subtitles only]" - - - Dim Pfad2 As String - Dim TextBox2_Text As String = Nothing - Dim CR_FilenName As String = Nothing - Dim ObjectJson As String = Nothing - Me.Invoke(New Action(Function() As Object - TextBox2_Text = Anime_Add.TextBox2.Text - Return Nothing - End Function)) - - ' - Dim Loc_CR_Cookies = " -H " + Chr(34) + CR_Cookies + Chr(34) - - Dim Loc_AuthToken = " -H " + Chr(34) + "Authorization: " + AuthToken + Chr(34) - - If CBool(InStr(AuthToken, "Authorization")) = True Then - Loc_AuthToken = AuthToken - End If - - Dim CR_EpisodeID As String = "" - - - Dim ObjectsURLBuilder() As String = Streams.Split(New String() {"videos"}, System.StringSplitOptions.RemoveEmptyEntries) + Dim ObjectsURLBuilder() As String = Streams.Split(New String() {"videos"}, System.StringSplitOptions.RemoveEmptyEntries) Dim ObjectsURLBuilder2() As String = ObjectsURLBuilder(1).Split(New String() {"/streams"}, System.StringSplitOptions.RemoveEmptyEntries) Dim ObjectsURLBuilder3() As String = WebsiteURL.Split(New String() {"watch/"}, System.StringSplitOptions.RemoveEmptyEntries) Dim ObjectsURLBuilder4() As String = ObjectsURLBuilder3(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries) @@ -1747,10 +1112,12 @@ Public Class Main 'Filter JSON esqaped characters 'Debug.WriteLine(Date.Now.ToString + "before:" + ObjectJson) - Debug.WriteLine("1288: " + ObjectJson) + Debug.WriteLine("1750: " + ObjectJson) ObjectJson = CleanJSON(ObjectJson) 'Debug.WriteLine(Date.Now.ToString + "after:" + ObjectJson) + Dim DubsAvalible As New List(Of CR_MediaVersion) + Dim ser As JObject = JObject.Parse(ObjectJson) Dim data As List(Of JToken) = ser.Children().ToList @@ -1787,8 +1154,30 @@ Public Class Main CR_episode_duration_ms = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") Case "is_dubbed" CR_audio_isDubbed = CBool(SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "")) - 'Case "eligible_region" - ' CR_Region = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") + Case "audio_locale" + CR_audio_locale = SubEntry.Value.ToString.Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") + Case "versions" 'each record is inside the entries array + For Each VersionEntry As JObject In item.Values + + Dim VideoSubData As List(Of JToken) = VersionEntry.Children().ToList + Dim guid As String = Nothing + Dim audio_locale As String = Nothing + + For Each VideoSubItem As JProperty In VideoSubData + Select Case VideoSubItem.Name + Case "audio_locale" + audio_locale = VideoSubItem.Value.ToString + Case "guid" + guid = VideoSubItem.Value.ToString + 'Debug.WriteLine(guid) + End Select + Next + + If audio_locale = Nothing Or guid = Nothing Then + Else + DubsAvalible.Add(New CR_MediaVersion(audio_locale, guid)) + End If + Next End Select Next ' End Select @@ -1798,197 +1187,30 @@ Public Class Main Next -#Region "VideoJson" - - Dim cms As String = CurlAuthNew("https://www.crunchyroll.com/index/v2", Loc_CR_Cookies, Loc_AuthToken) - - 'MsgBox(cms) - - Dim cms_web() As String = cms.Split(New String() {Chr(34) + "cms_web" + Chr(34) + ":"}, System.StringSplitOptions.RemoveEmptyEntries) - 'Dim cms_web() As String = cms.Split(New String() {Chr(34) + "cms_beta" + Chr(34) + ":"}, System.StringSplitOptions.RemoveEmptyEntries) - - Dim bucket1() As String = cms_web(1).Split(New String() {Chr(34) + "bucket" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) - Dim bucket2() As String = bucket1(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) - Dim bucket As String = bucket2(0) - - Dim policy1() As String = cms_web(1).Split(New String() {Chr(34) + "policy" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) - Dim policy2() As String = policy1(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) - Dim policy As String = policy2(0) - - Dim signature1() As String = cms_web(1).Split(New String() {Chr(34) + "signature" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) - Dim signature2() As String = signature1(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) - Dim signature As String = signature2(0) - - Dim key_pair_id1() As String = cms_web(1).Split(New String() {Chr(34) + "key_pair_id" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) - Dim key_pair_id2() As String = key_pair_id1(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) - Dim key_pair_id As String = key_pair_id2(0) - - 'key_pair_id - 'cms_web - Dim Videos1() As String = Streams.Split(New String() {"v2/cms"}, System.StringSplitOptions.RemoveEmptyEntries) - Dim Videos2() As String = Videos1(1).Split(New String() {"streams"}, System.StringSplitOptions.RemoveEmptyEntries) - Dim Videos As String = Videos2(0) - 'MsgBox(Videos) - Dim VideoJson As String = Nothing - Dim StreamUrl As String = "https://www.crunchyroll.com/cms/v2" + bucket + Videos + "streams?Policy=" + policy + "&Signature=" + signature + "&Key-Pair-Id=" + key_pair_id - 'MsgBox(StreamUrl) - VideoJson = CurlAuthNew(StreamUrl, Loc_CR_Cookies, Loc_AuthToken) 'Curl(StreamUrl) ' - - 'VideoJson = CurlAuthNew(Streams, Loc_CR_Cookies, Loc_AuthToken) - Debug.WriteLine("VideoJson: " + VideoJson) - Debug.WriteLine("VideoStreams: " + Streams) - - - Dim CR_HardSubLang As String = SubSprache.CR_Value - VideoJson = CleanJSON(VideoJson) - - 'MsgBox(VideoJson) -#End Region - -#Region "Check for dub override" - - Try - - - Dim OverrideDubJObject As JObject = JObject.Parse(VideoJson) - Dim OverrideDubData As List(Of JToken) = OverrideDubJObject.Children().ToList - - Dim DubsAvalible As New List(Of CR_MediaVersion) - - For Each item As JProperty In OverrideDubData - item.CreateReader() - Select Case item.Name - Case "versions" 'each record is inside the entries array - For Each Entry As JObject In item.Values - - Dim VideoSubData As List(Of JToken) = Entry.Children().ToList - Dim media_guid As String = Nothing - Dim audio_locale As String = Nothing - - For Each VideoSubItem As JProperty In VideoSubData - Select Case VideoSubItem.Name - Case "audio_locale" - audio_locale = VideoSubItem.Value.ToString - 'Debug.WriteLine(audio_locale) - Case "media_guid" - media_guid = VideoSubItem.Value.ToString - 'Debug.WriteLine(media_guid) - End Select - Next - - If audio_locale = Nothing Or media_guid = Nothing Then - Else - DubsAvalible.Add(New CR_MediaVersion(audio_locale, media_guid)) - End If - Next - Case "audio_locale" 'each record is inside the entries array - 'MsgBox(item.Value) - If CR_audio_isDubbed = True Then - Dim AudioTag As String = CStr(item.Value) - CR_audio_locale = String.Join(" ", AudioTag.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c).Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") - Else - CR_audio_locale = "ja-JP" - End If - End Select - Next - 'MsgBox(CR_audio_locale + vbNewLine + DubSprache.CR_Value) - - If My.Settings.OverrideDub = True And CR_audio_locale = DubSprache.CR_Value = False Then 'einstellung ein + kein musikvideo oder Konzert - 'MsgBox("Trigger on!") - For i As Integer = 0 To DubsAvalible.Count - 1 - If DubsAvalible(i).AudioLang = DubSprache.CR_Value Then - Dim NewStream As String = "https://www.crunchyroll.com/cms/v2" + bucket + "/videos/" + DubsAvalible(i).media_guid + "/" + "streams?Policy=" + policy + "&Signature=" + signature + "&Key-Pair-Id=" + key_pair_id - 'MsgBox(NewStream) - VideoJson = CurlAuthNew(NewStream, Loc_CR_Cookies, Loc_AuthToken) 'Curl(StreamUrl) ' - - End If - Next - - - End If - - Catch ex As Exception - - End Try - 'MsgBox("Trigger off!") - - -#End Region - #Region "m3u8 suche" - 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 - Case "streams" 'each record is inside the entries array - 'For Each Entry As JProperty In item.Values - - ' Dim JsonEntryFormat As String = Entry.Name - ' If CBool(InStr(Entry.Name, "drm")) Or CBool(InStr(Entry.Name, "dash")) Or CBool(InStr(Entry.Name, "urls")) Then - ' Continue For - ' End If +#Region "Check for dub override" + If My.Settings.OverrideDub = True And CR_audio_locale = DubSprache.CR_Value = False Then 'einstellung ein + kein musikvideo oder Konzert + 'MsgBox("Trigger on!") + For i As Integer = 0 To DubsAvalible.Count - 1 + If DubsAvalible(i).AudioLang = DubSprache.CR_Value Then + page_guid = DubsAvalible(i).guid + End If + Next + End If +#End Region + End If - - ' Dim SubData As List(Of JToken) = Entry.Children().ToList - ' For Each SubItem As JObject In SubData - ' SubItem.CreateReader() - - ' Dim StreamFormats As List(Of JToken) = SubItem.Children().ToList - - - ' For Each Formats As JProperty In StreamFormats - ' Formats.CreateReader() - ' Dim SubLang As String = Formats.Name - ' If SubLang = Nothing Or SubLang = "" Then - ' SubLang = "null" - ' End If - - ' Dim Url As String = CStr(Formats.Value("url")) - - - ' 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 - ' Next - 'Next - Case "audio_locale" 'each record is inside the entries array - 'MsgBox(item.Value) - If CR_audio_isDubbed = True Then - Dim AudioTag As String = CStr(item.Value) - CR_audio_locale = String.Join(" ", AudioTag.Split(invalids, StringSplitOptions.RemoveEmptyEntries)).TrimEnd("."c).Replace(Chr(34), "").Replace("\", "").Replace("/", "").Replace(":", "") - Else - CR_audio_locale = "ja-JP" - End If - End Select - Next - - 'If download_hls IsNot Nothing Then - ' CR_Streams.Add(download_hls) - 'End If - - Dim NewAPI_0 As String() = WebsiteURL.Split(New String() {"watch/"}, System.StringSplitOptions.RemoveEmptyEntries) - Dim NewAPI_1 As String() = NewAPI_0(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries) - - - Dim NewAPI As String = "https://cr-play-service.prd.crunchyrollsvc.com/v1/" + NewAPI_1(0) + "/console/switch/play" + Dim NewAPI As String = "https://cr-play-service.prd.crunchyrollsvc.com/v1/" + page_guid + "/console/switch/play" + Debug.WriteLine("NewAPI: " + NewAPI) Dim NewAPIData As String = CurlAuthNew(NewAPI, "", Loc_AuthToken) + Debug.WriteLine("NewAPIData: " + NewAPIData) - 'MsgBox(NewAPIData) Dim VideoJSON_New As String = CleanJSON(NewAPIData) @@ -2052,7 +1274,7 @@ Public Class Main ElseIf CR_URI_Master.Count = 0 Then Me.Invoke(New Action(Function() As Object - ResoNotFoundString = VideoJson + ResoNotFoundString = VideoJSON_New DialogTaskString = "Language_CR_Beta" ErrorDialog.ShowDialog() Return Nothing @@ -2412,15 +1634,8 @@ Public Class Main ffmpegInput = "-i [Subtitles only]" Else - - Dim str As String = CurlAuthNew(CR_URI_Master(0), "", Loc_AuthToken) - - - - - If CBool(InStr(str, "curl:")) = True Or str = Nothing Then Debug.WriteLine("Checked " + CR_URI_Master.Count.ToString) @@ -2491,31 +1706,31 @@ Public Class Main #Region "GetSoftsubs" Dim SoftSubsAvailable As New List(Of String) - Dim CCAvailable As New List(Of String) + 'Dim CCAvailable As New List(Of String) Dim SoftSubsList As New List(Of CR_Subtiles) - Dim SplitVideo As String() = VideoJson.Split(New String() {Chr(34) + "closed_captions" + Chr(34) + ":"}, System.StringSplitOptions.RemoveEmptyEntries) + 'Dim SplitVideo As String() = VideoJson.Split(New String() {Chr(34) + "closed_captions" + Chr(34) + ":"}, System.StringSplitOptions.RemoveEmptyEntries) - If SoftSubs.Count > 0 And My.Settings.Captions = True Then + 'If SoftSubs.Count > 0 And My.Settings.Captions = True Then + ' For i As Integer = 0 To SoftSubs.Count - 1 + ' If CBool(InStr(SplitVideo(1), Chr(34) + "locale" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34))) Then + ' CCAvailable.Add(SoftSubs(i)) + ' End If + ' Next + 'End If + '"language":"de-DE" + If SoftSubs.Count > 0 Then 'And CCAvailable.Count = 0 Then For i As Integer = 0 To SoftSubs.Count - 1 - If CBool(InStr(SplitVideo(1), Chr(34) + "locale" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34))) Then - CCAvailable.Add(SoftSubs(i)) - End If - Next - End If - - If SoftSubs.Count > 0 And CCAvailable.Count = 0 Then - For i As Integer = 0 To SoftSubs.Count - 1 - If CBool(InStr(VideoJson, Chr(34) + "locale" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34))) Then + If CBool(InStr(VideoJSON_New, Chr(34) + "language" + Chr(34) + ":" + Chr(34) + SoftSubs(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34))) Then SoftSubsAvailable.Add(SoftSubs(i)) End If Next - ElseIf SoftSubs.Count > 0 And CCAvailable.Count > 0 Then - SoftSubsAvailable.AddRange(CCAvailable) + 'ElseIf SoftSubs.Count > 0 And CCAvailable.Count > 0 Then + ' SoftSubsAvailable.AddRange(CCAvailable) End If @@ -2532,7 +1747,7 @@ Public Class Main ffmpegInput = "-i " + Chr(34) + Pfad6 + Chr(34) + " " + ffmpegInput + " -map 0 -map 1:a" + " -metadata:s:a:" + FFMPEG_Audio(Pfad6).ToString + " language=" + ConvertSubValue(CR_audio_locale, ConvertSubsEnum.MP4CC_ISO_639_2) + " -c copy" - ElseIf SoftSubsAvailable.Count > 0 Or CCAvailable.Count > 0 Then + ElseIf SoftSubsAvailable.Count > 0 Then 'Or CCAvailable.Count > 0 Then Dim MergeSubsNow As Boolean = MergeSubs @@ -2544,13 +1759,13 @@ Public Class Main For i As Integer = 0 To SoftSubsAvailable.Count - 1 - Dim SubsJson As String = VideoJson - If CCAvailable.Count > 0 Then - SubsJson = SplitVideo(1) - End If + Dim SubsJson As String = VideoJSON_New + 'If CCAvailable.Count > 0 Then + ' SubsJson = SplitVideo(1) + 'End If - Dim SoftSub As String() = SubsJson.Split(New String() {Chr(34) + "locale" + Chr(34) + ":" + Chr(34) + SoftSubsAvailable(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) + Dim SoftSub As String() = SubsJson.Split(New String() {Chr(34) + "language" + Chr(34) + ":" + Chr(34) + SoftSubsAvailable(i) + Chr(34) + "," + Chr(34) + "url" + Chr(34) + ":" + Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries) Dim SoftSub_2 As String() = SoftSub(1).Split(New [Char]() {Chr(34)}) Dim SoftSub_3 As String = SoftSub_2(0).Replace("&", "&").Replace("/u0026", "&").Replace("\u002F", "/").Replace("\u0026", "&") SoftSubsList.Add(New CR_Subtiles(SoftSubsAvailable(i), ConvertSubValue(SoftSubsAvailable(i), ConvertSubsEnum.DisplayText), " -i " + Chr(34) + SoftSub_3 + Chr(34), i.ToString, SoftSubsAvailable(i) = DefaultSubCR)) @@ -2598,9 +1813,9 @@ Public Class Main For i As Integer = 0 To SoftSubsList.Count - 1 Dim SubFormat As String = "ass" - If CCAvailable.Count > 0 Then - SubFormat = "vtt" - End If + 'If CCAvailable.Count > 0 Then + ' SubFormat = "vtt" + 'End If Dim i2 As Integer = i Me.Invoke(New Action(Function() As Object Anime_Add.StatusLabel.Text = "Status: downloading subtitle file " + SoftSubsList(i2).SubLangName diff --git a/Crunchyroll Downloader/My Project/AssemblyInfo.vb b/Crunchyroll Downloader/My Project/AssemblyInfo.vb index 412e561..5637ece 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: ' - - + +