Aerion / uptobox-dl

An Uptobox/Uptostream batch downloader.
MIT License
52 stars 11 forks source link

Some ideas #9

Closed redyolocraft closed 1 year ago

redyolocraft commented 1 year ago

Salut, j'ai une requête à formuler, mais je ne suis pas sûr de l'endroit approprié pour le faire, alors je la pose ici. Tout d'abord, permettez-moi de vous exprimer ma gratitude pour le travail que vous effectuez et également pour l'augmentation du délai d'attente. Serait-il possible que le logiciel puisse télécharger tous les fichiers d'un dossier Uptobox si je lui donne un lien correspondant ? De plus, serait-il envisageable de créer un fichier contenant tous les liens que je fournis au logiciel, de sorte que si le programme s'arrête, je puisse le relancer avec un paramètre permettant de reprendre là où il s'est arrêté ? Serait-il également possible que si le programme se termine de manière inattendue, il puisse se relancer avec cette option ?

Hello, I have a features request, but I'm not sure where to do it, so I'm asking it here. First of all, allow me to express my gratitude for the work you are doing and also for extending the timeout period. Would it be possible for the software to download all the files from an Uptobox folder if I provide a corresponding link? Additionally, would it be feasible to create a file containing all the links I provide to the software, so that if the program stops, I can relaunch it with a parameter to resume from where it left off? Would it also be possible that if the program crashes, it can restart with this option?

Aerion commented 1 year ago

Hi, Thanks for the ideas :) I'll keep the messages in English for future readers.

Would it be possible for the software to download all the files from an Uptobox folder if I provide a corresponding link?

It's feasible and should be relatively simple to implement according to https://docs.uptobox.com/?javascript#retrieve-files-in-public-folder

Additionally, would it be feasible to create a file containing all the links I provide to the software, so that if the program stops, I can relaunch it with a parameter to resume from where it left off? Would it also be possible that if the program crashes, it can restart with this option?

Does it occur often that the program crashes and that one needs to restart it by resuming? I'm not sure about the additional complexity for a "simple" download tool.

By any chance, would you be willing to implement one of the above features? Cheers

redyolocraft commented 1 year ago

Hello,

It's feasible and should be relatively simple to implement according to https://docs.uptobox.com/?javascript#retrieve-files-in-public-folder

It's really great to discover that Uptobox has documentation; I wasn't aware of that. It's truly commendable on their part.

Does it occur often that the program crashes and that one needs to restart it by resuming?

On my end, I've noticed that it crashes often. Here are the logs from the last crash:

Unhandled exception. System.Net.WebException: Une tentative de connexion a échoué car le parti connecté n'a pas répondu convenablement au-delà d'une certaine durée ou une connexion établie a échoué car l'hôte de connexion n'a pas répondu. (www55.uptobox.com:443) ---> System.Net.Http.HttpRequestException: Une tentative de connexion a échoué car le parti connecté n'a pas répondu convenablement au-delà d'une certaine durée ou une connexion établie a échoué car l'hôte de connexion n'a pas répondu. (www55.uptobox.com:443) ---> System.Net.Sockets.SocketException (10060): Une tentative de connexion a échoué car le parti connecté n'a pas répondu convenablement au-delà d'une certaine durée ou une connexion établie a échoué car l'hôte de connexion n'a pas répondu. at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError , CancellationToken ) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 ) at System.Net.Sockets.Socket.gWaitForConnectWithCancellation|277_0(AwaitableSocketAsyncEventArgs , ValueTask , CancellationToken ) at System.Net.HttpWebRequest.<>c__DisplayClass216_0.<b1>d.MoveNext() --- End of stack trace from previous location --- at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String , Int32 , HttpRequestMessage , Boolean , CancellationToken ) --- End of inner exception stack trace --- at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String , Int32 , HttpRequestMessage , Boolean , CancellationToken ) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage , Boolean , CancellationToken ) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage , Boolean , CancellationToken ) at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage ) at System.Threading.Tasks.TaskCompletionSourceWithCancellation1.WaitWithCancellationAsync(CancellationToken ) at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage , Boolean , CancellationToken ) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage , Boolean , Boolean , CancellationToken ) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage , Boolean , CancellationToken ) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage , HttpCompletionOption , CancellationTokenSource , Boolean , CancellationTokenSource , CancellationToken ) at System.Net.HttpWebRequest.SendRequest(Boolean ) at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult ) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult ) at System.Net.WebClient.GetWebResponse(WebRequest , IAsyncResult ) at System.Net.WebClient.GetWebResponseTaskAsync(WebRequest ) at System.Net.WebClient.DownloadBitsAsync(WebRequest , Stream , AsyncOperation , Action3 ) at UptoboxDl.Program.DownloadFile(Uri link, String filename) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\Program.cs:line 141 at UptoboxDl.Program.ProcessLink(String link, Options opts) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\Program.cs:line 91 at UptoboxDl.Program.Main(String[] args) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\Program.cs:line 58 at UptoboxDl.Program.

(String[] args)

It appears that an unhandled exception occurred in the code. The exception is of type System.Net.WebException and it indicates a failed connection attempt. The error message suggests that the connection to the server www55.uptobox.com on port 443 didn't receive a response. The code seems to be written in C# and utilizes the System.Net.WebClient class for a download operation from the Uptobox website. However, the connection attempt fails, resulting in this exception.

I want to emphasize that my connection is stable, with a download speed of 1 Gbps and a ping below 10. Additionally, I'm connected via wired connection.

It seems that when Uptobox changes its SSL certificate while I'm downloading, it also causes a crash.

I suggest implementing a feature that automatically retries the connection whenever there's a connection error, continuing until the connection is established, even if it requires infinite attempts.

I will try to make it save the links to a text file, but I'm currently in the final stretch of my academic year with a lot of exams ahead. Moreover, my programming skills are somewhat limited. Once I finish my academic year, I will delve into it. Could you take care of downloading the files from the Uptobox folder in the meantime?

I'm not sure about the additional complexity for a "simple" download tool.

"Behind simple things lie great efforts."

Could you please keep this conversation open?

Aerion commented 1 year ago

The new version v1.3.0 handles uptobox folder links 🎉 I also added some retry mechanism to hopefully reduce the crashes you mentioned when uptobox fails to respond. Feel free to try it out!

redyolocraft commented 1 year ago

I have tried several folder links but it crashes. Here's the message it gives me. Unhandled exception. System.Text.Json.JsonException: The JSON value could not be converted to UptoboxDl.UptoboxClient.PublicFolder. Path: $ | LineNumber: 0 | BytePositionInLine: 8. at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type ) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , T& ) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , T& ) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& ) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 , JsonTypeInfo , Nullable1 ) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 , JsonTypeInfo ) at System.Text.Json.JsonSerializer.Deserialize[TValue](String , JsonSerializerOptions ) at UptoboxDl.UptoboxClient.Client.GetAsync[T](Uri uri, CancellationToken ct) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\UptoboxClient\Client.cs:line 107 at UptoboxDl.UptoboxClient.Client.GetFolderFileCodes(String folder, String hash) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\UptoboxClient\Client.cs:line 84 at UptoboxDl.Program.GetFileCodesFromUrls(IReadOnlyList`1 links, String userToken) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\Program.cs:line 88 at UptoboxDl.Program.Main(String[] args) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\Program.cs:line 61 at UptoboxDl.Program.

(String[] args) 'folder' n’est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes.

I gave the crash logs to ChatGPT and it's telling me this. ChatGPT ( It seems that there is an unhandled exception in your code related to JSON serialization. The error message indicates that there is an issue converting a JSON value to the UptoboxDl.UptoboxClient.PublicFolder type.

The specific error message suggests that the JSON value at the root level cannot be converted. It might be helpful to check the JSON data you are trying to deserialize and ensure that it is valid and matches the expected structure.

Here are a few suggestions to help debug and resolve the issue:

  1. Verify the JSON data: Make sure the JSON data you are trying to deserialize is valid and well-formed. Check if the JSON structure matches the expected structure for the UptoboxDl.UptoboxClient.PublicFolder type.

  2. Check the JSON property names: Ensure that the property names in the JSON data match the property names in the UptoboxDl.UptoboxClient.PublicFolder type. The deserialization process relies on matching property names.

  3. Check the JSON data types: Verify that the data types of the JSON values match the expected types in the UptoboxDl.UptoboxClient.PublicFolder type. For example, if a property is expected to be an integer, make sure it contains a valid integer value in the JSON data.

  4. Review the serialization settings: If you have custom serialization settings or converters, review them to ensure they are correctly configured for the UptoboxDl.UptoboxClient.PublicFolder type. Make sure any custom converters are registered and applied correctly.

  5. Handle exceptions and logging: Consider adding exception handling and logging to your code to provide more detailed information about the error. This can help in pinpointing the exact cause of the issue.

Regarding the last line of the error message, it appears to be a separate issue where the command or program named 'folder' is not recognized. This might be unrelated to the JSON deserialization error and could be a separate command or program that you are trying to execute.

By addressing the JSON deserialization issue based on the suggestions above, you should be able to resolve the error related to System.Text.Json.JsonException. )

Aerion commented 1 year ago

Could you put a folder url that resolves this issue? Or put the whole uptobox-dl command here? On my end when I tried with a folder that I created, the files were downloaded.

redyolocraft commented 1 year ago

By the way, I would like to say that this is a good addition.

24 files to download (from 24 direct links and 0 folders)

I left the folder link in the email inbox (lofofeffalli-1075@yopmail.com) on the yopmail.com website. By opening the folder link, you will understand why I prefer to share it with you this way. Please delete the email after copying the link.

I am executing this command. uptobox-dl -t mysecrettoken mysecretfolderlink

Edit : And also, the download speed has been multiplied by 4. Thank you very much.

Aerion commented 1 year ago

Thanks, I removed the mail from the yopmail inbox after grabbing the link.

I don't have any issue on my end with the link you provided:

$ ./uptobox-dl -t <REDACTED> 'https://uptobox.com/user_public?hash=<REDACTED>&folder=<REDACTED>'
8 files to download (from 0 direct links and 1 folders)
Start processing <REDACTED>
66256604B/880534047B: 7%

Could you please share the output of the same command you did, but by passing the --verbose --debug flags? e.g. ./uptobox-dl -t <REDACTED> 'https://uptobox.com/user_public?hash=<REDACTED>&folder=<REDACTED>' --verbose --debug

What will be of interest is the following

Getting uri: https://uptobox.com/api/user/public?folder=<REDACTED>&hash=<REDACTED>&limit=100&offset=0
Deserialized data: {"statusCode":0,"message":"Success","data":{"list":[{"file_name":" (...)

If you were to call it with the url https://uptobox.com/user_public?hash=fooooooooo&folder=baaaaaaaar, you should see

Getting uri: https://uptobox.com/api/user/public?folder=baaaaaaaar&hash=fooooooooo&limit=100&offset=0

On which OS are you running uptobox-dl, is it Windows, Linux? Maybe you could try running the command by putting the link in single quotes like my example above?

redyolocraft commented 1 year ago

First of all, I would like to say that the retry mechanisms work very well.

I'm not sure if the options --verbose --debug will provide any additional information.

D:\uptobox-dl-v1.3.0-win-x64>uptobox-dl -t REDACTED 'https://uptobox.com/user_public?hash=REDACTED&folder=REDACTED' Unhandled exception. System.Exception: Unknown link format: 'https://uptobox.com/user_public?hash=REDACTED at UptoboxDl.Program.GetFileCodesFromUrls(IReadOnlyList`1 links, String userToken) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\Program.cs:line 94 at UptoboxDl.Program.Main(String[] args) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\Program.cs:line 61 at UptoboxDl.Program.

(String[] args) 'folder' n’est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes.

D:\uptobox-dl-v1.3.0-win-x64>uptobox-dl -t REDACTED 'https://uptobox.com/user_public?hash=REDACTED&folder=REDACTED' --verbose --debug Unhandled exception. System.Exception: Unknown link format: 'https://uptobox.com/user_public?hash=REDACTED at UptoboxDl.Program.GetFileCodesFromUrls(IReadOnlyList`1 links, String userToken) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\Program.cs:line 94 at UptoboxDl.Program.Main(String[] args) in D:\a\uptobox-dl\uptobox-dl\uptobox-dl\Program.cs:line 61 at UptoboxDl.Program.

(String[] args) 'folder' n’est pas reconnu en tant que commande interne ou externe, un programme exécutable ou un fichier de commandes.

The computer it is running on is a Windows 10 LTSC 2021. It's a really clean version of Windows 10 Enterprise.

Aerion commented 1 year ago

I see, the issue is that uptobox-dl is not receiving the full commandline because of the & character. Are you using powershell or cmd.exe as a command prompt? See https://stackoverflow.com/questions/1327431/how-do-i-escape-ampersands-in-batch-files

Could you try to put the link in double quotes "https://...&folder=..."? Or to run it from powershell maybe?

To confirm it, try doing echo https://uptobox.com/user_public?hash=REDACTED&folder=REDACTED, you'll see the same error, wheras if it's quoted or run from powershell, you should have a single line being printed with https://uptobox.com/user_public?hash=REDACTED&folder=REDACTED.

Aerion commented 1 year ago

To go back on the initial issue, I added a simple mechanism that I believe could match what you were asking with the resume behavior: The new release v.1.40 will skip over a file that was already downloaded (present on disk with the same name and size). So if you launch uptobox-dl with multiple links (or folders), stop it, and re-start it with the same links, only the new files (or the one that was not fully downloaded) will be processed!

redyolocraft commented 1 year ago

I'm using CMD. I just tried it with double quotes and it works. Thank you very much for all the work. Do you want me to close the discussion or would you like to keep it open for future ideas?

Aerion commented 1 year ago

Let's close it, and if you find other issues/new ideas, feel free to create new ones Cheers :)