Closed satyamtg closed 3 years ago
Merging #59 into master will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## master #59 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 930 974 +44
=========================================
+ Hits 930 974 +44
Impacted Files | Coverage Δ | |
---|---|---|
src/zimscraperlib/download.py | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update e632586...7305f33. Read the comment docs.
Have done those changes. I think it looks better now.
Thanks, as discussed once, don't rewrite commits until it's reviewed otherwise we can't use partial diff.
This adds a
YoutubeDownloader
class indownload.py
to download youtube videos on a constant number of threads. It has a method calleddownload()
which allows it to work like a normal serial function that can be then parallelized in the scrapers. However, it downloads on its own executor, hence, the number of workers actually downloading the videos gets reduced to the limit that is set during initialization.The YoutubeDownloader has the following members -
executor
- A ThreadPoolExecutor which is initialized with a limited number of threadsvideo_format
- same as what we use in the scrapers (both webm and mp4 supported)The
YoutubeDownloader
has the following methods -__init__()
- Used to initialize theexecutor
and thevideo_format
shutdown()
- Used to shutdown the executor properly and must be called explicitly when there's no use of this classrun_youtube_dl()
- The method which downloads the videos usingyoutube_dl
download()
- A method to run therun_youtube_dl()
method on the executor with correct URL and return its return value or raise an exceptionWe can run the download() method parallely on several number of threads, but videos will download in a fixed number of threads. We can do it something like this (a similar test is also there) -