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

Why is my cookie file blank (Using api) #21158

Closed
kenkit opened this issue May 19, 2019 · 3 comments
Closed

Why is my cookie file blank (Using api) #21158

kenkit opened this issue May 19, 2019 · 3 comments
Labels

Comments

@kenkit
Copy link

@kenkit kenkit commented May 19, 2019

Checklist

  • I'm asking a question
  • I've looked through the README and FAQ for similar questions
  • I've searched the bugtracker for similar questions including closed ones

Question

WRITE QUESTION HERE

import youtube_dl
import json
from youtube_dl.compat import compat_cookiejar, compat_urllib_request
from youtube_dl.utils import make_HTTPS_handler, YoutubeDLHandler

def youtube_get(url):
    params={}
    jar = compat_cookiejar.MozillaCookieJar("cooke.txt")
    cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
    proxies = compat_urllib_request.getproxies()
    proxy_handler = compat_urllib_request.ProxyHandler(proxies)
    https_handler = make_HTTPS_handler(params)
    ydlh = YoutubeDLHandler(params)
    opener = compat_urllib_request.build_opener(https_handler, proxy_handler, cookie_processor, ydlh)
    compat_urllib_request.install_opener(opener)
    y=youtube_dl.YoutubeDL({'outtmpl':u'','skip_download':True,'dumpjson': True,'dump_single_json': True}, auto_init=False)
    y.add_default_info_extractors()
    object = y.extract_info(url, download=False)
    jar.save()
    return json.dumps(object);

I'm new to python, using some code I found on https://programtalk.com/python-examples/youtube_dl.YoutubeDL/
Thanks in advance

@kenkit kenkit added the question label May 19, 2019
@dstftw
Copy link
Collaborator

@dstftw dstftw commented May 20, 2019

You should not touch anything apart from options dict where you must set cookiefile.

@dstftw dstftw closed this May 20, 2019
@dstftw dstftw added the invalid label May 20, 2019
@kenkit
Copy link
Author

@kenkit kenkit commented May 20, 2019

Hi, thanks for responding. I don't get what you mean by touching the options dict, but how do I improve that code.
If you could write a few lines on how I can fix this I'd be most greatfull, I'm using that function from a c++ program, after coming from using cmdline.

@kenkit
Copy link
Author

@kenkit kenkit commented May 21, 2019

@dstftw Can you please show me how to solve this ?

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.