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

youtube-dl doesn't login again for each instance #13252

Closed
ghost opened this issue Jun 1, 2017 · 2 comments
Closed

youtube-dl doesn't login again for each instance #13252

ghost opened this issue Jun 1, 2017 · 2 comments

Comments

@ghost
Copy link

@ghost ghost commented Jun 1, 2017

I want to download multiple files using youtube-dl from a site the needs login.
The issue that I have is that youtube-dl is login for the first video with no issue, but doesn't login again for next video.

How do I force youtube-dl to login for each video, every time the function is called ?

def video_download(path, url):

        ydl = youtube_dl.YoutubeDL(
            {
                'outtmpl': path + '.mp4',
                'format': 'bestvideo+bestaudio/best',
                'username': email,
                'password': password,
                'cachedir': False,
                'noplaylist': True
                # 'quiet': True

            })

        with ydl:
            ydl.download([url])
        time.sleep(45)

I use multiple instances, because the function run in a loop and create a new instance each time. Also I tried different names.

def video_download(path, url, email, password, i):
    ydl = {}
    ydl[i] = youtube_dl.YoutubeDL( ..

Different instances, the first one is working, the next don't login again.Terminal/Output::

<youtube_dl.YoutubeDL.YoutubeDL object at 0x00000000050E4C18>
[safari] Downloading login form
[safari] Login successful
[safari] 9781787283664/video1_1: Downloading webpage
.............................
<youtube_dl.YoutubeDL.YoutubeDL object at 0x000000000337DD68>
[safari] 9781787283664/video1_2: Downloading webpage
[safari] 9781787283664/video1_2: Downloading kaltura session JSON
WARNING: Unable to download kaltura session JSON: HTTP Error 401: UNAUTHORIZED

Please give a working example. Thank you.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jun 1, 2017

ydl_opts = {
    'username': '...',
    'password': '...',
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['BaW_jenozKc'])

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['UxxajLWwzqY'])
[youtube] Downloading login page
[youtube] Looking up account info
[youtube] Logging in
[youtube] Checking cookie
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading video info webpage
[youtube] BaW_jenozKc: Extracting video information
WARNING: unable to extract uploader nickname
[youtube] BaW_jenozKc: Downloading MPD manifest
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[download] Destination: youtube-dl test video ''_ä↭𝕐-BaW_jenozKc.f137.mp4
[download] 100% of 2.11MiB in 00:00
[download] Destination: youtube-dl test video ''_ä↭𝕐-BaW_jenozKc.f251.webm
[download] 100% of 186.27KiB in 00:00
[ffmpeg] Merging formats into "youtube-dl test video ''_ä↭𝕐-BaW_jenozKc.mkv"
Deleting original file youtube-dl test video ''_ä↭𝕐-BaW_jenozKc.f137.mp4 (pass -k to keep)
Deleting original file youtube-dl test video ''_ä↭𝕐-BaW_jenozKc.f251.webm (pass -k to keep)
[youtube] Downloading login page
[youtube] Looking up account info
[youtube] Logging in
[youtube] Checking cookie
[youtube] UxxajLWwzqY: Downloading webpage
[youtube] UxxajLWwzqY: Downloading video info webpage
[youtube] UxxajLWwzqY: Extracting video information
WARNING: unable to extract uploader nickname
[youtube] UxxajLWwzqY: Downloading js player en_US-vflDmabfQ
[youtube] UxxajLWwzqY: Downloading MPD manifest
[download] Destination: Icona Pop - I Love It (feat. Charli XCX) [OFFICIAL VIDEO]-UxxajLWwzqY.f136.mp4
[download]  93.3% of 38.57MiB at  9.66MiB/s ETA 00:00

[youtube] Logging in
[youtube] Checking cookie
[youtube] BaW_jenozKc: Downloading webpage

[youtube] Logging in
[youtube] Checking cookie
[youtube] UxxajLWwzqY: Downloading webpage

@dstftw dstftw closed this Jun 1, 2017
@dstftw dstftw added the invalid label Jun 1, 2017
@ghost
Copy link
Author

@ghost ghost commented Jun 1, 2017

I used the same example as yours with https://www.safaribooksonline.com/ and is not working. It is logging only first time.

@ytdl-org ytdl-org locked and limited conversation to collaborators Jun 1, 2017
@dstftw dstftw removed the invalid label Jun 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.