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

Python - Video already downloaded. #2015

Closed
ProgramErgoSum opened this issue Dec 19, 2013 · 5 comments
Closed

Python - Video already downloaded. #2015

ProgramErgoSum opened this issue Dec 19, 2013 · 5 comments

Comments

@ProgramErgoSum
Copy link

@ProgramErgoSum ProgramErgoSum commented Dec 19, 2013

I have a need to invoke youtube-dl from a Python code I am having. All my attempts to download the video ends with a message about the video being already downloaded. I am using -o option to specify a full path to a .mp4 file and this path does not have the said file. So, I am not sure, why am I getting this error message.

The code is somewhat like this:

import youtube_dl
ydlOpts=['-o','/path/to/video.mp4','youtubeVideoId']
youtube_dl.main(ydlOpts)

I could confirm that the youtube-dl being invoked is the one I downloaded from this GitHub page by a print statement in the _real_main(). I also changed the sys.exit to a return so that the whole Python script wouldn't end up there itself (and, it doesn't).

@ghost
Copy link

@ghost ghost commented Dec 19, 2013

This works for me.

import os
from youtube_dl import YoutubeDL

directory = os.path.join(os.path.expanduser('~'), 'YoutubeVideos') # path to download folder

ydl_options = {
    'outtmpl': os.path.join(directory, '%(title)s-%(id)s.%(ext)s'),
    'nocheckcertificate': True,
}

with YoutubeDL(ydl_options) as ydl:
    ydl.add_default_info_extractors()
    ydl.download(['http://www.youtube.com/watch?v=CYNxFaLwvSg'])

If file exists it throws errors

FileExistsError: [WinError 183] Nelze vytvořit soubor, který již existuje: 'C:\\Documents and Settings\\pulpe\\YoutubeVideos\\Drumsound & Bassline Smith - Nicaragua-CYNxFaLwvSg.mp4'
....
youtube_dl.utils.DownloadError: ERROR: unable to rename file
@ProgramErgoSum
Copy link
Author

@ProgramErgoSum ProgramErgoSum commented Dec 20, 2013

I give it a try quickly; it didn't work. I am going to explore some more
and report back.

@ProgramErgoSum
Copy link
Author

@ProgramErgoSum ProgramErgoSum commented Dec 20, 2013

It works! Trying to tweak it for a playlist URL.

Sent from phone. Pardon spelling and grammar mistakes.
On 20 Dec 2013 02:59, "pulpe" notifications@github.com wrote:

This works for me.

import os
from youtube_dl import YoutubeDL

directory = os.path.join(os.path.expanduser('~'), 'YoutubeVideos') # path to download folder

ydl_options = {
'outtmpl': os.path.join(directory, '%(title)s-%(id)s.%(ext)s'),
'nocheckcertificate': True,
}

with YoutubeDL(ydl_options) as ydl:
ydl.add_default_info_extractors()
ydl.download(['http://www.youtube.com/watch?v=CYNxFaLwvSg'])

If file exists it throws errors

FileExistsError: [WinError 183] Nelze vytvoøit soubor, který ji¾ existuje: 'C:\Documents and Settings\pulpe\YoutubeVideos\Drumsound & Bassline Smith - Nicaragua-CYNxFaLwvSg.mp4'
....
youtube_dl.utils.DownloadError: ERROR: unable to rename file

Reply to this email directly or view it on GitHubhttps://github.com//issues/2015#issuecomment-30968210
.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Dec 21, 2013

Can we close the issue then?

@ProgramErgoSum
Copy link
Author

@ProgramErgoSum ProgramErgoSum commented Dec 21, 2013

Yes, please.

Sent from phone. Pardon spelling and grammar mistakes.
On 21 Dec 2013 17:17, "Jaime Marquínez Ferrándiz" notifications@github.com
wrote:

Can we close the issue then?


Reply to this email directly or view it on GitHubhttps://github.com//issues/2015#issuecomment-31061807
.

@jaimeMF jaimeMF closed this Dec 21, 2013
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.