Skip to content
This repository has been archived by the owner on Jul 13, 2024. It is now read-only.

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
fix AoD ffmpeg command issue
workaround funimation certifcate error
fix add-on setting default value issue
  • Loading branch information
hama3254 committed Feb 28, 2021
1 parent 9246423 commit 29793c0
Show file tree
Hide file tree
Showing 20 changed files with 294 additions and 77 deletions.
Binary file modified .vs/Crunchyroll Downloader/v15/.suo
Binary file not shown.
Binary file modified .vs/Crunchyroll Downloader/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file modified .vs/Crunchyroll Downloader/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file modified .vs/Crunchyroll Downloader/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
3 changes: 2 additions & 1 deletion CRD-addon/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<button type="button" class='btn_class' id='btn_add_funimation'>Add this Funimation Episode</button>
<button type="button" class='btn_class' id='btn_add'>Add this Crunchyroll Episode</button>
<button type="button" class='btn_class' id='btn_add_AoD'>Add this Series</button>
<button type="button" class='btn_class' id='btn_add_mass'>Add selected Episodes</button>
<button type="button" class='btn_class' id='btn_add_mass'>Add selected Crunchyroll Episodes</button>
<button type="button" class='btn_class' id='btn_add_mass_funimation'>Add selected Funimation Episodes</button>
<button type="button" class='btn_class' id='btn_enable_select'>Select Episodes</button>
<button type="button" class='btn_class' id='btn_select_all'>Select All</button>
<button type="button" class='btn_class' id='btn_select_none'>Deselect All</button>
Expand Down
59 changes: 54 additions & 5 deletions CRD-addon/popup.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
var Port;
var FunCookie;
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_enable_select").hidden = true;
document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_select_all").hidden = true;
document.getElementById("btn_select_none").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_add_mass_funimation").hidden = true;
document.getElementById("btn_add_AoD").hidden = true;

browser.storage.local.get("CRD_Port")
Expand Down Expand Up @@ -205,8 +207,9 @@ document.getElementById('btn_add').addEventListener('click', () => {
});

document.getElementById('btn_add_funimation').addEventListener('click', () => {

var add_fun = browser.tabs.executeScript({
code: "javascript:void(0);" //"document.getElementsByClassName('show-details')[0].innerHTML;"
code: "document.cookie" //"document.getElementsByClassName('show-details')[0].innerHTML;"
});
add_fun.then(add_fun_ok, add_one_error);

Expand All @@ -221,6 +224,15 @@ document.getElementById('btn_add_mass').addEventListener('click', () => {

});

document.getElementById('btn_add_mass_funimation').addEventListener('click', () => {

var add_mass = browser.tabs.executeScript({
code: 'var i,URLList="";for(i=0;i<document.getElementsByClassName("CRD-Selected").length;i++)URLList+=document.getElementsByClassName("CRD-Selected")[i].getAttribute("href");URLList;'
});
add_mass.then(add_mass_fun_ok, add_mass_error);

});

function onExecuted(result) {
console.log(result[0]);

Expand Down Expand Up @@ -275,7 +287,7 @@ function add_fun_ok(result) {
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "http://127.0.0.1:" + Port + "/post", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("FunimationURL=" + tab.url);
xhttp.send("FunimationURL=" + tab.url + "&FunimationCookie=" + result);

setTimeout(function () {
document.getElementById("btn_add_funimation").style.background = "#ff8000"
Expand Down Expand Up @@ -328,6 +340,27 @@ function add_mass_ok(result) {

}

function add_mass_fun_ok(result) {

document.getElementById("btn_add_mass_funimation").disabled = true;
document.getElementById("btn_add_mass_funimation").style.background = "#c9c9c9"

var postdata = result + "&FunimationCookie=" + FunCookie

var xhttp = new XMLHttpRequest();
xhttp.open("POST", "http://127.0.0.1:" + Port + "/post", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("FunimationMass=" + postdata);

setTimeout(function () {
document.getElementById("btn_add_mass_funimation").style.background = "#ff8000"
}, 10000);
setTimeout(function () {
document.getElementById("btn_add_mass_funimation").disabled = false;
}, 10000);

}

function add_mass_error(error) {
console.log(`Error: ${error}`);
}
Expand All @@ -339,22 +372,31 @@ document.getElementById('btn_enable_funimation_select').addEventListener('click'
code: 'var script=document.createElement("script");script.type="text/javascript",script.src="http://127.0.0.1:' + Port + '/inject_funimation.js",document.head.appendChild(script);'
}); //load script from local CRD Server included in https://github.com/hama3254/Crunchyroll-Downloader-v3.0

document.getElementById("btn_add_mass").hidden = false;
document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_add_mass_funimation").hidden = false;
document.getElementById("btn_select_all").hidden = false;
document.getElementById("btn_select_none").hidden = false;
document.getElementById("btn_enable_select").hidden = true;
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_add_AoD").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = true;

});

function fun_cookie_ok(result) {

FunCookie = result;

}

function FunimationSuccess(result) {
console.log(result[0]);

if (result[0].includes('javascript:')) {
document.getElementById("btn_add").hidden = true;
document.getElementById("btn_add_mass").hidden = false;
document.getElementById("btn_add_mass").hidden = true;
document.getElementById("btn_add_mass_funimation").hidden = false;
document.getElementById("btn_select_all").hidden = false;
document.getElementById("btn_select_none").hidden = false;
document.getElementById("btn_enable_select").hidden = true;
Expand All @@ -363,6 +405,10 @@ function FunimationSuccess(result) {
document.getElementById("btn_enable_funimation_select").hidden = true;
document.getElementById("btn_add_funimation").hidden = true;
document.getElementById("btn_add_AoD").hidden = true;
var SaveFunimationCookie = browser.tabs.executeScript({
code: "document.cookie"
});
SaveFunimationCookie.then(fun_cookie_ok, add_mass_error);
console.log(true);
} else {
document.getElementById("btn_add").hidden = true;
Expand All @@ -373,7 +419,10 @@ function FunimationSuccess(result) {
document.getElementById("btn_select_none").hidden = true;
document.getElementById("btn_enable_funimation_select").hidden = false;
document.getElementById("btn_add_AoD").hidden = true;

var SaveFunimationCookie = browser.tabs.executeScript({
code: "document.cookie"
});
SaveFunimationCookie.then(fun_cookie_ok, add_mass_error);
console.log(false);
}
}
Expand Down
125 changes: 87 additions & 38 deletions Crunchyroll Downloader/Anime_Add.vb
Original file line number Diff line number Diff line change
Expand Up @@ -294,55 +294,58 @@ Public Class Anime_Add
AoDlogFileReader.Close()
AoDlogFileStream.Close()
If AoD_Cookie = Nothing Then

MsgBox(Main.LoginReminder)
Main.Text = "Crunchyroll Downloader"
Main.Invalidate()
StatusLabel.Text = "Status: idle"
Exit Sub
Main.Text = "Crunchyroll Downloader"
Main.Invalidate()
StatusLabel.Text = "Status: idle"
Exit Sub

End If
'MsgBox(AoD_Cookie)
'Main.WebbrowserCookie = AoD_Cookie
If CBool(InStr(Main.WebbrowserText, "/OmU/1080/hlsfirst/")) Then
Dim OmUStreamSplit() As String = Main.WebbrowserText.Split(New String() {"/OmU/1080/hlsfirst/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim OmUStreamSplitToken() As String = OmUStreamSplit(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)

Dim OmUStreamSplitEpisodeIndex() As String = OmUStreamSplit(0).Split(New String() {"/videomaterialurl/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim OmUStreamSplitEpisodeIndex2() As String = OmUStreamSplitEpisodeIndex(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim m3u8Strings As String = Nothing
'I/nsHttp Cookie:
Dim OmUStreamSplitEpisodeIndex2() As String = OmUStreamSplitEpisodeIndex(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim m3u8Strings As String = Nothing
'I/nsHttp Cookie:

Try
Using client As New WebClient()
client.Encoding = System.Text.Encoding.UTF8
client.Headers.Add(My.Resources.ffmpeg_user_agend.Replace(Chr(34), ""))
client.Headers.Add("ACCEPT: application/json, text/javascript, */*; q=0.01")
client.Headers.Add("Accept-Encoding: gzip, deflate, br")
client.Headers.Add("X-Requested-With: XMLHttpRequest")
client.Headers.Add(AoD_Cookie) '+ WebBrowser1.Document.Cookie)
'MsgBox(OmUStreamSplitEpisodeIndex(1))
m3u8Strings = client.DownloadString("https://www.anime-on-demand.de/videomaterialurl/" + OmUStreamSplitEpisodeIndex2(0) + "/OmU/1080/hlsfirst/" + OmUStreamSplitToken(0))
'("Sub: " + m3u8Strings)
End Using
Catch ex As Exception
MsgBox(ex.ToString + vbNewLine + "https://www.anime-on-demand.de/videomaterialurl/" + OmUStreamSplitEpisodeIndex2(0) + "/OmU/1080/hlsfirst/" + OmUStreamSplitToken(0))
End Try
If m3u8Strings = Nothing Then
Else

Try
Using client As New WebClient()
client.Encoding = System.Text.Encoding.UTF8
client.Headers.Add(My.Resources.ffmpeg_user_agend.Replace(Chr(34), ""))
client.Headers.Add("ACCEPT: application/json, text/javascript, */*; q=0.01")
client.Headers.Add("Accept-Encoding: gzip, deflate, br")
client.Headers.Add("X-Requested-With: XMLHttpRequest")
client.Headers.Add(AoD_Cookie) '+ WebBrowser1.Document.Cookie)
'MsgBox(OmUStreamSplitEpisodeIndex(1))
m3u8Strings = client.DownloadString("https://www.anime-on-demand.de/videomaterialurl/" + OmUStreamSplitEpisodeIndex2(0) + "/OmU/1080/hlsfirst/" + OmUStreamSplitToken(0))
'("Sub: " + m3u8Strings)
End Using
Catch ex As Exception
MsgBox(ex.ToString + vbNewLine + "https://www.anime-on-demand.de/videomaterialurl/" + OmUStreamSplitEpisodeIndex2(0) + "/OmU/1080/hlsfirst/" + OmUStreamSplitToken(0))
End Try
If m3u8Strings = Nothing Then
Else
Dim OmUStreams() As String = m3u8Strings.Split(New String() {My.Resources.AoD_files}, System.StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 1 To OmUStreams.Count - 1
AoD_OmUList.Add(OmUStreams(i))
Next
End If

Dim OmUStreams() As String = m3u8Strings.Split(New String() {My.Resources.AoD_files}, System.StringSplitOptions.RemoveEmptyEntries)
For i As Integer = 1 To OmUStreams.Count - 1
AoD_OmUList.Add(OmUStreams(i))
Next
End If

End If

If CBool(InStr(Main.WebbrowserText, "/Dub/1080/hlsfirst/")) Then
If CBool(InStr(Main.WebbrowserText, "/Dub/1080/hlsfirst/")) Then
Dim DubStreamSplit() As String = Main.WebbrowserText.Split(New String() {"/Dub/1080/hlsfirst/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim DubStreamSplitToken() As String = DubStreamSplit(1).Split(New String() {Chr(34)}, System.StringSplitOptions.RemoveEmptyEntries)
Dim DubStreamSplitEpisodeIndex() As String = DubStreamSplit(0).Split(New String() {"/videomaterialurl/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim DubStreamSplitEpisodeIndex2() As String = DubStreamSplitEpisodeIndex(1).Split(New String() {"/"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim m3u8Strings As String = Nothing
'I/nsHttp Cookie:

Try
Using client As New WebClient()
client.Encoding = System.Text.Encoding.UTF8
Expand Down Expand Up @@ -689,11 +692,57 @@ Public Class Anime_Add
End If

Main.Funimation_Grapp_RDY = False
GeckoFX.WebBrowser1.Navigate(UriUsed)
Main.WebbrowserURL = UriUsed
ListBox1.Items.Remove(ListBox1.Items(0))
Main.b = False
'Main.b = False
StatusLabel.Text = "Status: loading ..."
Main.Text = "Status: loading ..."
If Main.SystemWebBrowserCookie IsNot Nothing Then
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Try
Using client As New WebClient()
client.Headers.Add("User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0")
client.Headers.Add("ACCEPT: application/json, text/javascript, */*; q=0.01")
client.Headers.Add("Accept-Encoding: gzip, deflate, br")
client.Headers.Add("Cookie:" + Main.SystemWebBrowserCookie)
Dim HTMLString As String = DecompressString(client.DownloadData(Main.WebbrowserURL))

If InStr(HTMLString, My.Resources.Funimation_Player_ID) Then
Dim WebbrowserHeadTextSplit() As String = HTMLString.Split(New String() {"<head"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim WebbrowserHeadTextSplit2() As String = WebbrowserHeadTextSplit(1).Split(New String() {"</head>"}, System.StringSplitOptions.RemoveEmptyEntries)

Dim WebbrowserTitleSplit() As String = HTMLString.Split(New String() {"<title>"}, System.StringSplitOptions.RemoveEmptyEntries)
Dim WebbrowserTitleSplit2() As String = WebbrowserTitleSplit(1).Split(New String() {"</title>"}, System.StringSplitOptions.RemoveEmptyEntries)


Main.WebbrowserText = HTMLString
Main.WebbrowserTitle = "<title>" + WebbrowserTitleSplit2(0) + "</title>"
Main.WebbrowserHeadText = "<head" + WebbrowserHeadTextSplit2(0) + "</head>"
Main.WebbrowserCookie = Main.SystemWebBrowserCookie

Dim t As Thread
t = New Thread(AddressOf Main.Funitmation_Grapp)
t.Priority = ThreadPriority.Normal
t.IsBackground = True
t.Start()

Else
Me.Invoke(New Action(Function()
Main.Text = "Status: no video found"
Me.StatusLabel.Text = "fail?"
Return Nothing
End Function))

End If
End Using
Catch ex As Exception
MsgBox(ex.ToString)
Exit Sub
End Try
Else
GeckoFX.WebBrowser1.Navigate(UriUsed)
End If
Main.Invalidate()
End If

Expand Down Expand Up @@ -768,6 +817,7 @@ Public Class Anime_Add
Dim ProcessList As New List(Of String)
Dim Dub As Boolean = False
Dim RDY As Boolean = True
Dim ffmpeg As String = Main.ffmpeg_command
Dim Running As Integer = Main.RunningDownloads
Dim DlMax As Integer = Main.MaxDL
Dim Pfad0 As String = Main.Pfad
Expand All @@ -788,6 +838,7 @@ Public Class Anime_Add

Me.Invoke(New Action(Function()
'Main.StatusMainForm.Text = "Crunchyroll Downloader"
ffmpeg = Main.ffmpeg_command
Pfad2 = Main.Pfad
NameMethode = Main.CR_NameMethode
If Main.AoD_Reso = 0 Then
Expand Down Expand Up @@ -1180,7 +1231,7 @@ Public Class Anime_Add
End If


Dim AoDm3u8Final As String = "-i " + Chr(34) + m3u8_url + Chr(34) + " " + Main.ffmpeg_command
Dim AoDm3u8Final As String = "-i " + Chr(34) + m3u8_url + Chr(34) + " " + ffmpeg
Dim DisplayReso As String = TargetReso.ToString + "p"
If AoD_1080pPlus = True Then
DisplayReso = "1080p+"
Expand Down Expand Up @@ -1365,7 +1416,5 @@ Public Class Anime_Add
End If
End Sub

Private Sub Anime_Add_DoubleClick(sender As Object, e As EventArgs) Handles Me.DoubleClick
'
End Sub

End Class
17 changes: 2 additions & 15 deletions Crunchyroll Downloader/CRD_List_Item.vb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Imports System.ComponentModel
Imports MetroFramework
Imports MetroFramework.Components
Imports MetroFramework.Forms
Imports System.IO.Compression


Public Class CRD_List_Item
Inherits Controls.MetroUserControl
Expand Down Expand Up @@ -1355,22 +1355,9 @@ Public Class CRD_List_Item
End Try
End Sub

Public Function DecompressString(ByVal bytes As Byte()) As String

Using ms = New MemoryStream(bytes)
Using ds = New GZipStream(ms, CompressionMode.Decompress)
Using sr = New StreamReader(ds)

Return sr.ReadToEnd()

End Using
End Using
End Using

End Function

End Class


Public Class FailedSegemtsWithURL
Public path As String
Public url As String
Expand Down
Loading

0 comments on commit 29793c0

Please sign in to comment.