Commit Graph

232 Commits

Author SHA1 Message Date
rlaphoenix 53c005f727 Remove unnecessary dl stop event set on CTRL+C 2023-02-28 18:05:04 +00:00
rlaphoenix 9cfda3bb9c Don't shutdown pool or the for loop will lock
Since I'm using `futures.as_completed()`, it will never ever for loop over all tracks and segments and will forever be stuck in the primary thread of the operation. I.e., main thread for the download track threads, or the track thread for the download segment threads.

I've also removed all future cancelled checks as they will never be cancelled before they get the chance to run, because no future cancel calls are made anymore.
2023-02-28 18:05:03 +00:00
rlaphoenix 51fb7920c9 Mark track as skipped if it never got a chance to start downloading 2023-02-28 16:39:33 +00:00
rlaphoenix acead803bd Remove unnecessary sleep calls at start of download threads 2023-02-28 16:38:10 +00:00
rlaphoenix b6d3c8368a Update CONFIG docs to use proxy_providers
Also removes an old unused `proxies` config option.
2023-02-28 16:32:13 +00:00
rlaphoenix 961747b74c Set the default aria2c --file-allocation to prealloc
Falloc is faster, but supports less systems/environments, and usually require admin perms on Windows.
2023-02-28 16:23:34 +00:00
rlaphoenix ce53a1b636 Don't run aria2c under asyncio, further improve progress updates
I've removed asyncio usage as it's generally unnecessary. If you want to run aria2c under a thread, run it under a thread. In the case for devine, this would take another thread, and would be another thread layer deep. Pointless. Would affect speed.

With this change I've been able to improve the aria2c progress capture code quite a bit.
2023-02-28 08:21:55 +00:00
rlaphoenix d427ec8472 Fix yet another startup crash when loading the config 2023-02-28 06:30:12 +00:00
rlaphoenix 3cfc679294 Center ASCII banner without using U+2800 2023-02-28 06:03:42 +00:00
rlaphoenix dc55f6ffeb Calculate DASH and HLS download speed in an alternate way
Also fixes getting download sizes for Subtitle tracks
2023-02-28 06:03:27 +00:00
rlaphoenix f4122f1ae6 Add mapping for Netflix profiles starting with `h264`
e.g., the new -qc profiles.
2023-02-28 06:02:36 +00:00
rlaphoenix e5e3f4687d Fix printing of aria2c errors if progress is used
Also improves the general process of ingesting aria2c progress information.
2023-02-27 16:52:00 +00:00
rlaphoenix 18449c4777 Ignore ERROR prints from aria2c progress checks 2023-02-27 00:00:55 +00:00
rlaphoenix 7560ee96c9 Replace console.log calls with padded console.prints
While console.log is currently removing the need for `Padding(..., (0, 5))` as it is overwritten to do it automatically, but in terms of purpose the `console.print` function is more logical.

I hope to find a way to automate the padding within console.print in the future, but for now this will work.
2023-02-26 23:35:40 +00:00
rlaphoenix eb3f268d64 Revert back to using logging over console.log where possible
It seems the commit I made to do this change initially seemed to help, it was actually pointless and issues I had were caused by other problems.

For consistency it seems best to stick with the logging module with the RichHandler applied. Using just console.log means being unable to control the log level and which level of logs appear.
2023-02-26 21:20:43 +00:00
rlaphoenix 401d0481df Implement verbose arg on tree method of Movies and Album 2023-02-26 19:04:54 +00:00
Arias800 d028957e9c Implement `add` and `delete` sub-commands to `wvd`
This pull request adds the features that are detailed in this issue:
https://github.com/devine-dl/devine/issues/2

Also changes some debug logs to info logs, as the information would generally be wanted. Also changes some logging logs to console.logs.
2023-02-26 18:46:09 +00:00
rlaphoenix 6419c27e0a Remove spacer from Spinner of progress bars 2023-02-26 15:57:10 +00:00
rlaphoenix a8c1612eb5 Remove unused TextColumn from Track progress bar 2023-02-26 15:56:04 +00:00
rlaphoenix 73b68fe7fe Use OnMultiplex for auto SDH-strip subtitle 2023-02-25 22:00:44 +00:00
rlaphoenix fe320e177d Add OnMultiplex event, for pre-multiplex 2023-02-25 21:58:32 +00:00
rlaphoenix 2635538205 Move repack to post-download, use rich status 2023-02-25 21:25:24 +00:00
rlaphoenix 7d1af8bd8c Move sub conversion to post-download, use rich status 2023-02-25 21:20:50 +00:00
rlaphoenix 8b405b6e02 Skip CC extraction if the binary isn't found 2023-02-25 21:06:11 +00:00
rlaphoenix a5c6052292 Move CC extraction to be post-download, use rich status 2023-02-25 21:04:04 +00:00
rlaphoenix b535715166 Print download thread exceptions with rich traceback 2023-02-25 17:47:59 +00:00
rlaphoenix 70106d32ce Log DRM license info under track downloads 2023-02-25 17:21:13 +00:00
rlaphoenix 178bd01069 Add a rich horizontal rule print on Service construction 2023-02-25 14:04:13 +00:00
rlaphoenix e9b3b3a588 Use rich status when checking for proxy geofence 2023-02-25 14:03:41 +00:00
rlaphoenix cd0c419142 Print available tracks in a Panel 2023-02-25 14:01:46 +00:00
rlaphoenix 4a5aebbca7 Add a total elapsed timer to the final log of dl command 2023-02-25 14:01:25 +00:00
rlaphoenix 09d6c4e1c3 Add a log when download finishes, listing file path 2023-02-25 14:00:39 +00:00
rlaphoenix a5da7c8fbd Add rich progress bar for the mux operation
Update dl.py
2023-02-25 13:58:58 +00:00
rlaphoenix 58673590df Remove unnecessary if check for --skip-dl
This would always be a true statement as this part of the code is already in an if else statement checking skip_dl.
2023-02-25 13:55:44 +00:00
rlaphoenix 92895426b3 Replace tqdm progress bars with rich progress bars 2023-02-25 13:45:17 +00:00
rlaphoenix cc69423374 Remove logs stating available/selected tracks
These are now unnecessary to distinguish as only one of the two will appear in the log depending what args are used.
2023-02-25 13:19:45 +00:00
rlaphoenix 96f408ca49 Only log available tracks if --list is used
Update dl.py
2023-02-25 13:12:46 +00:00
rlaphoenix 984582d19d Replace Tracks.print() calls with new rich tree 2023-02-25 13:10:49 +00:00
rlaphoenix 48e35fb4c4 Add rich tree generator to tracks wrapper 2023-02-25 13:05:56 +00:00
rlaphoenix 97b3dbeed2 Re-implement title listing with rich tree
Note that the full title list will no longer be printed unless --list-titles is used.
2023-02-25 13:02:00 +00:00
rlaphoenix f7c4d72108 Add rich tree generator to sorted title wrappers 2023-02-25 13:01:09 +00:00
rlaphoenix 92774dcfe6 Simplify str representation of Sorted title containers 2023-02-25 12:54:37 +00:00
rlaphoenix 389fa6e979 Use console.rule between sections of dl's new logs
These are handy to separate the logs to be per-title, and per section of initialization.
2023-02-25 12:52:51 +00:00
rlaphoenix b2bbc808c4 Use console.status across dl command 2023-02-25 12:22:32 +00:00
rlaphoenix 62d91a3e77 Replace log.info calls with console.log calls
I've moved log.info calls to console.log calls to reduce conflicts of logs at the same time as console refreshes, but also to reduce unnecessary log level text being printed to the console.

We don't need to know if a log is an `info` level log, but I've kept log.error's and such as we would want to know if a log is an error log and such.
2023-02-25 12:11:17 +00:00
rlaphoenix 3e1a067724 Override the default traceback with rich traceback 2023-02-25 11:53:44 +00:00
rlaphoenix b8f3118775 Replace version logs with new ASCII banner log 2023-02-25 11:51:03 +00:00
rlaphoenix f1864ad63c Replace logging handler with ComfyRichHandler
This changes all logs via logging to be printed to the rich console instead. Specifically, using my custom ComfyRichHandler making the logs padded horizontally.

In this change the time is no longer printed. The log level is still printed but it's now the full log name in bold.
2023-02-25 11:47:39 +00:00
rlaphoenix 8d626822cb Remove coloredlogs and now unused log constants 2023-02-25 11:46:03 +00:00
rlaphoenix 77c16f557c Replace logging FileHandler with console.save_text 2023-02-25 11:38:02 +00:00
rlaphoenix 34a2a8e4e6 Create custom Comfy versions of Console, LogRender, and RichHandler
These add a bit of margin around all console prints/logs. It makes the logs feel a bit more comfortable rather than being crammed edge-to-edge in the terminal.

The methods used here are by no means good, but they work quite well. If you can find a better way to do it, please make a pull request.
2023-02-25 11:33:42 +00:00
rlaphoenix 6eac499ae0 Add new config option to set the terminal bg color
This is a hacky way to do it, but it works surprisingly well, considering there's no true way to modify a terminal's fully color scheme.
2023-02-25 11:29:46 +00:00
rlaphoenix 01e419d52c Create custom-themed 80-width rich console 2023-02-25 11:27:29 +00:00
rlaphoenix 0f0000bdd0 Bump to v1.4.0 2023-02-25 23:05:14 +00:00
rlaphoenix 7958ad5e7c Create blank config if it did not exist 2023-02-25 23:01:11 +00:00
rlaphoenix 570e0aba00 Fix printing of download worker exceptions 2023-02-25 14:46:43 +00:00
rlaphoenix a8694cb049 Disable Insecure Request Warnings
These seem to occur when using HTTP+S proxies when connecting to a HTTPS URL. E.g., NordVPN proxies to https://google.com. While not ideal, we can't solve this solution and the warning logs are quite annoying.
2023-02-25 11:56:23 +00:00
rlaphoenix eebe76b6f6 Fix segment download merging on Linux machines
It seems on Windows the pathlib.iterdir() function is always in order. However, on Linux or at least some machines this is not the case. This change fixes the order.

If you think you were affected, check your previous downloads that used DASH or HLS segmentation and make sure they dont randomly change scenes out of order.
2023-02-24 23:10:51 +00:00
rlaphoenix c6976a7112 Move --log from the dl cmd to the root cmd 2023-02-24 19:54:05 +00:00
rlaphoenix 4f1cff681c Increase connection pool limit to accommodate Byte-Range dls 2023-02-24 19:46:26 +00:00
rlaphoenix ad82eab712 Pad/depad data when decrypting with ClearKey DRM 2023-02-23 18:19:51 +00:00
rlaphoenix 45c9ba5198 Add support for data URIs from HLS playlists in ClearKey 2023-02-23 18:19:51 +00:00
rlaphoenix 221cd1c283 Fix JOC check on HLS playlists with no audio channel info 2023-02-23 18:19:51 +00:00
rlaphoenix 1f86775ac9 Add support for segment downloads with byte-ranges
Adds support for HLS's EXT-X-BYTERANGE and DASH's SegmentBase.
2023-02-23 18:19:51 +00:00
rlaphoenix 55da41c74f Remove byte_range param on aria2c downloader
Turns out, even if you manually set the Range header AND the server has full support, it does not work. It will act like it works, but it seems internally aria2c gets confused on what bytes it requested, what it returned, and it will either just download the full file, or the range requested (but still complain, and freeze!).

Yikes.
2023-02-23 16:47:14 +00:00
rlaphoenix da1beae28f Bump to v1.3.1 2023-02-23 09:25:34 +00:00
rlaphoenix 739c17bf4c Initialize config when adding auth if non-existant 2023-02-23 09:09:09 +00:00
rlaphoenix 9932fa3f7a Fix mistake when logging where the cookie file was moved 2023-02-23 09:07:21 +00:00
rlaphoenix 3b5a199f31 Fix regression of missing title & track when licensing with Widevine
For some reason I had the partial removed and replaced with the direct function, meaning services using `title` and `track` during the license and service cert functions would crash.
2023-02-23 08:56:37 +00:00
varyg fc19358de4 Fix regression of missing track.path on URL downloads 2023-02-23 08:44:50 +00:00
rlaphoenix 2aea4549ce Bump to v1.3.0 2023-02-22 04:39:42 +00:00
rlaphoenix 2ad3f04a5e Use the session DRM as the initial DRM for HLS
The variant-playlist may have DRM information that won't be in the invariant (stream) playlist. We need to begin with this DRM data if available.
2023-02-22 04:30:24 +00:00
rlaphoenix c1f716cb6c Drop support for Python 3.8 2023-02-22 03:43:22 +00:00
rlaphoenix f21aa5aac5 Silence aria2c when downloading segmented streams
It conflicts with the TQDM progress bar, it's also not really useful information.
2023-02-22 03:06:53 +00:00
rlaphoenix 4406e3bbab Add ability to silence aria2c's output 2023-02-22 03:06:17 +00:00
rlaphoenix 0913b0dda6 Add ability to set extra arguments with aria2c 2023-02-22 03:01:54 +00:00
rlaphoenix 1443dfaecc Replace Threading Pool system with Thread Storage in Vaults
This fixes the usage of vaults across different threads. It now makes a truly unique connection for each thread. The previous code did this as well, but put back the connection from x thread, to re-use in y thread. Now it simply creates and reuses the connection on their own thread.

Once the thread is closed, the data is now also garbage collected. This now reduces the risk of filling up memory over time.
2023-02-22 01:31:03 +00:00
rlaphoenix 4e875f5ffc Multi-thread the new DASH download system, improve redundency
Just like the commit for HLS multi-threading, this mimics the -j=16 system of aria2c, but manually via a ThreadPoolExecutor. Benefits of this is we still keep support for the new system, and we now get a useful progress bar via TQDM on segmented downloads, unlike aria2c which essentially fills the terminal with jumbled download progress stubs.
2023-02-22 01:06:24 +00:00
rlaphoenix 9e6f5b25f3 Multi-thread the new HLS download system
This mimics the -j=16 system of aria2c, but manually via a ThreadPoolExecutor. Benefits of this is we still keep support for the new system, and we now get a useful progress bar via TQDM on segmented downloads, unlike aria2c which essentially fills the terminal with jumbled download progress stubs.
2023-02-21 16:16:12 +00:00
rlaphoenix 314079c75f Pass save path to DRM decrypt functions directly
This is required in segmented scenarios when multi-threaded where the same `track.path` would be get and set from possibly at the same time. It's also just better logically to do it this way.
2023-02-21 16:09:35 +00:00
rlaphoenix 8268825ba8 Use Widevine.from_init_data when downloading DASH
This is required as some DASH manifests do not explicitly list the PSSH with the Widevine ContentProtection, only listing that its a supported.
2023-02-21 08:02:32 +00:00
rlaphoenix 8c312440a3 Add func to get Widevine PSSH and KID from Init Data
This is just a more direct alternative to Widevine.from_track where you may have the init data but not the track itself.
2023-02-21 08:00:42 +00:00
rlaphoenix 50193856c2 Add missing tqdm progress bar to DASH downloads 2023-02-21 06:35:40 +00:00
rlaphoenix 61270d3af4 Fix expired check in some cases in Cacher class
It seems if a service sets the expiration time in seconds or by a timestamp, then this resolves as expired up to 14 hrs too early, or 14 hours too late, depending on what your timezone is relative to UTC+00:00.

However, I haven't fully confirmed if this is the right fix to make. As in, I'm not sure if changing datetime.utcnow() to datetime.now() should be done, or the other way around. However, I've had multiple people tell me changing it this way worked for them so I'm just going to roll with it.
2023-02-21 06:13:02 +00:00
rlaphoenix 42aaa03941 Completely rewrite downloading system
The new system now downloads and decrypts segments individually instead of downloading all segments, merging them, and then decrypting. Overall the download system now acts more like a normal player.

This fixes #23 as the new HLS download system detects changes in keys and init segments as segments are downloaded. DASH still only supports one period, and one period only, but hopefully I can change that in the future.

Downloading code is now also moved from the Track classes to the manifest classes. Download progress is now also actually helpful for segmented downloads (all HLS, and most DASH streams). It uses TQDM to show a progress bar based on how many segments it needs to download, and how fast it downloads them.

There's only one down side currently. Downloading of segmented videos no longer have the benefit of aria2c's -j parameter. Where it can download n URLs concurrently. Aria2c is still used but only -x and -s is going to make a difference.

In the future I will make HLS and DASH download in a multi-threaded way, sort of a manual version of -j.
2023-02-21 06:00:39 +00:00
rlaphoenix c925cb8af9 Remove AtomicSQL, use Connection Pools in Vaults
This allows the use of vaults in any thread, while keeping database-file level thread safety. AtomicSQL doesn't actually do anything that useful.
2023-02-21 05:38:39 +00:00
rlaphoenix 707469d252 Add ability to pass a proxy to ClearKey in HLS.get_drm 2023-02-21 01:37:39 +00:00
rlaphoenix 5197961d91 Add doc-string to HLS.get_drm 2023-02-21 01:36:01 +00:00
rlaphoenix 09989f8b94 Raise error if no supported drm was found in HLS.get_drm 2023-02-21 01:31:52 +00:00
rlaphoenix c3f2d0d9cc Support HLS's EXT-X-KEY NONE
If EXT-X-KEY of Method=NONE is encountered, it assumes no DRM should be used, even if other supported DRM may have already been or is going to be iterated.
2023-02-21 01:24:04 +00:00
rlaphoenix 7025b5cef3 Only convert AES-128 EXT-X-KEYs to ClearKey objects
There's other AES methods like AES-CBC and such that is not currently supported by the ClearKey DRM class.
2023-02-21 01:21:28 +00:00
varyg f412b0e37f
Check if cookies exists 2023-02-14 21:56:55 +01:00
rlaphoenix be87d897e3 Bump to v1.2.0 2023-02-13 20:04:47 +00:00
rlaphoenix 6d3caffa32 Backport Path.is_relative_to to Python 3.8.x
Further Fix to #28.
2023-02-13 19:07:24 +00:00
rlaphoenix d926b4fe9a Fix annotation type-hints in some files on Python 3.x
Fixes #28.
2023-02-13 19:06:25 +00:00
rlaphoenix af5e6acbb8 Add byte-range option to the aria2c downloader 2023-02-13 18:43:36 +00:00
varyg bb9e85d777 Use shutil.move to move data instead of Path.rename
Path.rename() cannot move data to different drives. It can only rename the path reference on the same file system. However, shutil.move() will move the data while also changing it's name.
2023-02-13 18:33:02 +00:00
Arias800 7169eaa885
Detect redirection
If the manifest is hidden behind a redirect, the url is not updated and the segments are created with the old url.
I found a French service where this situation occurred.

After this change, it was possible to correctly parse the mpd.
2023-02-12 11:01:16 +01:00
rlaphoenix 4b5a2c703b Fix subtitle conversion error where WEBVTT header is kept
This happened because the WEBVTT header was segmented and appended to each other without enough newline separation so pycaption thought it was an actual caption and to be kept.
2023-02-11 22:17:43 +00:00
rlaphoenix 47448aac3c Print traceback when download worker fails 2023-02-11 22:16:54 +00:00
rlaphoenix f4363ae57e Fix HLS conversion of JOC Audio Tracks channels 2023-02-11 17:12:22 +00:00
rlaphoenix 067130990c Add missing exit when --abitrate returns no tracks 2023-02-10 21:11:28 +00:00
rlaphoenix d612599e27 Add Audio Channels Selection option to dl command CLI
Sub-channel layouts like 5.1, 7.1, will match with e.g., 6.0 and 8.0 respectively.

Closes #9.
2023-02-10 21:10:09 +00:00
rlaphoenix f9afd87474 Parse audio channels to float, rework parse function
The function now works more effectively, now supports parsing `Nch` strings and explicitly tests for float/int input.
2023-02-10 20:58:33 +00:00
rlaphoenix 0334640e93 Remove unnecessary audio channel 'Nch' differential
This was implemented to know the difference between services explicitly stating 5.1 channel audio, to a service explicitly stating 6.0 channel audio that is likely 5.1 channel layout.

However, since technically both are 6 channels, this is unnecessary and just causes complications.
2023-02-10 20:46:26 +00:00
rlaphoenix f34bdb8627 If audio channels weren't specified, don't insinuate 2ch 2023-02-10 20:34:46 +00:00
rlaphoenix 84bf9fde92 Add Bitrate Selection options to dl command CLI
It defaults to highest available. Closes #8.
2023-02-10 20:19:54 +00:00
rlaphoenix 4bee08c431 Fix FutureWarning when getting FPS for DASH videos 2023-02-10 20:05:31 +00:00
rlaphoenix a8f3975f7e Remove assert statements from base Service class
The 2nd assert statement is completely unnecessary, and the first one can be resolved by using it in an if instead.
2023-02-10 19:49:19 +00:00
rlaphoenix dbe52cf273 Remove list comp on parameter of any() 2023-02-10 19:44:03 +00:00
rlaphoenix 9a757708ac Make the get_session func of the Service class static 2023-02-10 19:41:58 +00:00
rlaphoenix 09e29cb2e1 Define exports with __ALL__ in sub-packages 2023-02-10 19:37:03 +00:00
rlaphoenix fae44614f5 Define all imports within the tracks package 2023-02-10 19:27:12 +00:00
rlaphoenix 268509fb49 Remove unused f-strings with no placeholders 2023-02-10 19:26:46 +00:00
rlaphoenix d982e37ee5 Re-order all imports across project with isort 2023-02-10 19:25:25 +00:00
rlaphoenix faabfb550c Replace use of with_stem + with_suffix to with_name 2023-02-10 19:13:31 +00:00
rlaphoenix 0a5f359217 Fix FutureWarning when getting segment URLs from SegmentTemplate 2023-02-08 12:57:09 +00:00
rlaphoenix 23153f0078 Only use SegmentBase's timescale as FPS if exists
Also optimised it to not require FPS.parse, as the Video class will run it under FPS.parse anyway.
2023-02-08 12:29:57 +00:00
rlaphoenix 71ded306b6 Bump to v1.1.0 2023-02-07 21:49:32 +00:00
rlaphoenix 18e2d8617e Create credentials dict prior to assignment in auth add
Fixes #17.
2023-02-07 21:32:21 +00:00
rlaphoenix c5d6ba09f2 Check if Cookie file for profile already exists during auth add
Fixes #16.
2023-02-07 21:25:26 +00:00
rlaphoenix 6619c29fb5 Create parent dirs when adding cookies with auth add
Fixes #21.
2023-02-07 21:21:15 +00:00
rlaphoenix 0446c44a42 Only iterate over cookie dir if exists in auth list
Fixes #18.
2023-02-07 21:08:45 +00:00
rlaphoenix 794de8b516 Efficiently store data in auth list, sort the data 2023-02-07 21:07:58 +00:00
rlaphoenix dd441bcd85 Fix crash when loading key vaults in dl command
Fixes #15.
2023-02-07 20:47:40 +00:00
rlaphoenix 1fa3ba61c8 Fix crash when using cfg on empty/new configs
Fixes #19.
2023-02-07 20:44:34 +00:00
rlaphoenix f7683173f8 Fix startup crash if config is blank
Fixes #20.
2023-02-07 20:32:40 +00:00
rlaphoenix 76671495b4 Fix startup crash if config does not yet exist
Fixes #14.
2023-02-07 20:20:40 +00:00
rlaphoenix 5301ac2924 Add util to test decoding of the video/audio streams with FFmpeg 2023-02-07 00:58:53 +00:00
rlaphoenix 00f85f7206 Add util to change video range flag losslessly
This is useful for some services. Some times there's a random stream with the wrong video range.
2023-02-06 23:49:28 +00:00
rlaphoenix 8b9247bfc5 Fix the organization name across the project
Sadly `devine` was not available.
2023-02-06 02:55:22 +00:00
rlaphoenix 7fd87b8aa2 Initial commit 2023-02-06 02:41:29 +00:00