Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ignore exceptions caused while downloading multiple videos #8442

Closed
ramadivyasri opened this issue Feb 6, 2016 · 4 comments
Closed

How to ignore exceptions caused while downloading multiple videos #8442

ramadivyasri opened this issue Feb 6, 2016 · 4 comments

Comments

@ramadivyasri
Copy link

@ramadivyasri ramadivyasri commented Feb 6, 2016

I'm trying to develop a python script to download a bunch of youtube videos which are inputted from a csv file using the youtube-dl module. The script stops as the download fails for a single video. I need the script to continue downloading the next videos ignoring the videos that cannot be downloaded. Can some one please help me on how to handle this in python?

My python code has ignoreerrors option enabled: ydl_opts = {'ignoreerrors':True,'progress_hooks': [my_hook],'format': fmt,'writeinfojson':True,'logger': MyLogger()} with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download([URL])

But it is not able to bypass and program exits with below error message ERROR: VqzpEw69Tze: YouTube said: This video does not exist

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Feb 6, 2016

Post the full source and playlist URL.

@ramadivyasri
Copy link
Author

@ramadivyasri ramadivyasri commented Feb 6, 2016

I cannot post full source code as it is proprietary.

ydl_opts = {'ignoreerros':True,'progress_hooks': [my_hook],'format': fmt,'writeinfojson':True,'logger': MyLogger()}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([URL])

The above is the heart of my code.
I'm inputting video id and format id from a csv file:
csv contains:

kfchvCyHmsc,18
vqzpEw69Tzc,22
cskYRDuZIes,22
lUtnas5ScSE,22
Lc-vINJmhNk,18

IF any of the above video does not exist, I need my code to continue downloading preceding videos. But as soon as a video is not found, the script terminates. how can I handle this?

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Feb 6, 2016

ydl_opts = {
    'ignoreerrors': True,
    'simulate': True,
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['kfchvCyHmsc', 'VqzpEw69Tze', 'vqzpEw69Tzc'])
[youtube] kfchvCyHmsc: Downloading webpage
[youtube] kfchvCyHmsc: Downloading video info webpage
[youtube] kfchvCyHmsc: Extracting video information
[youtube] kfchvCyHmsc: Downloading DASH manifest
[youtube] kfchvCyHmsc: Downloading DASH manifest
[youtube] VqzpEw69Tze: Downloading webpage
[youtube] VqzpEw69Tze: Downloading video info webpage
ERROR: VqzpEw69Tze: YouTube said: This video does not exist.
[youtube] vqzpEw69Tzc: Downloading webpage
[youtube] vqzpEw69Tzc: Downloading video info webpage
[youtube] vqzpEw69Tzc: Extracting video information
[youtube] vqzpEw69Tzc: Downloading DASH manifest
[youtube] vqzpEw69Tzc: Downloading DASH manifest

Perfectly skips as expected. ignoreerrors only makes sense on multple video URLs or a playlist URL. If you run download on a single video URL then run it on each URL and catch DownloadError yourself. I don't know whether you do so or not since you are not willing to post the code.

@dstftw dstftw closed this Feb 6, 2016
@ramadivyasri
Copy link
Author

@ramadivyasri ramadivyasri commented Feb 6, 2016

Thank you @dstftw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.