Fixes a bunch of bugs and improves a few features.
Fixes
- Fixed JQuery and HQuery taking wrong parameters
- Fixed Feed type parsing being messy
- Fixed video title fetched to time at initialisation
- Fixed categories not able to reverse
- Fixed Param bruteforce concatenation on by default
- Fixed threaded and FFMPEG download (still experimental)
- Params with a None value are now excluded from being concatenated to another (but not the reverse)
Improvements
- Refactored param concatenation to use `|` instead of `+`
- Implemented sort filter sequence check
- Added an HD constant for searching
- Documented Param assertions
- Implemented `Param._concat`, which concatenates n params together, with the option to bruteforce their concatenation (used internally to test for constant types)
- You can now use the `in` keyword to check if a Param is inside another
- Updated docstrings
- User search has more parameters (unsure of the format, experimental): country, city and age
- Using concurent.futures instead of threading for threaded downloads
Note on downloads
Downloading is becoming more stable. You can use 3 download backends for one video:
- `phub.download.default`, default and dummy backend. It simply fetches a segment one after the other. It is stable but quite slow.
- `phub.download.FFMPEG`, which let FFMPEG handle the whole download. It makes it really stable and fast, but as FFMPEG is a CLI tool, progress display is not available. Callback will be called at start (`0`) and at the end (`1`).
- `phub.download.threaded`, which uses a threaded concurent.futures pool to download everything as fast as possible. This is still experimental but already quite faster than a default download. You can also select the maximum number of workers and requests timeouts.
python
Default download
video.download(..., downloader = phub.download.default)
FFMPEG download
video.download(..., downloader = phub.download.FFMPEG)
Threaded download
video.download(..., downloader = phub.download.threaded(max_workers = 50, timeout = 30))
Note that the best threaded parameters will depend on your CPU and connection speed. I might want a higher timeout if you have a slower connection, and less workers if you have a weak CPU.
Note on download callbacks
A single download callback is not enough if you want a more precise way of keeping track of the downloading process, you can create your own custom callback object that inherits from `phub.objects.Callback`:
python
from phub import Callback
class Tracker(Callback):
def on_download(progress: int):
Execute stuff on download progress
print('Downloading', progress, '/', self.total)
def on_write(progress: int):
Execute stuff on write progress
print('Writing', progress, '/', self.total)
video.download(..., display = Tracker)
This should be useful, e.g. if you are trying to download very long videos that nescessite to keep track of their writing progress.
Simple callbacks functions that takes only 2 arguments are still available, but will be automatically trasnformed to Callback objects and only the download progress will be available. I might implement more functions into this tracker in the future (errors, retry stuff, etc.).