jaimeMF / youtube-dl-api-server

A youtube-dl REST API server
https://youtube-dl-api-server.readthedocs.org/
The Unlicense
364 stars 212 forks source link

extract_info() returns forbidden urls (403) #15

Closed romaincointepas closed 9 years ago

romaincointepas commented 10 years ago

This happens with some videos (like this one: https://www.youtube.com/watch?v=m1ET6SEtwbc)

I think it's never doing the _extract_signature_function() things (available in youtube extractor) when doing extract_info().

jaimeMF commented 10 years ago

It works fine here, how are you getting the information? are you using your own server?

romaincointepas commented 10 years ago

I'm on Appengine python. On your side, the 'url' field doesn't return a 403 ? Are you getting a 'player_url' field as well ?

jaimeMF commented 10 years ago

The url can be played fine on Firefox, mpv and I have downlaoded it with curl. I also get the player_url field, but I don't think that's a problem. I've looked in the logs and the signature extraction seems to be run. Are you selecting a specific format or the url from the main dictionary?

romaincointepas commented 10 years ago

Here is how I'm reproducing:

import sys
import webapp2
from google.appengine.api import urlfetch
import json
import youtube_dl

####################################################################

if not hasattr(sys.stderr, 'isatty'):
    sys.stderr.isatty = lambda: False

class SimpleYDL(youtube_dl.YoutubeDL):
    def __init__(self, *args, **kargs):
        super(SimpleYDL, self).__init__(*args, **kargs)
        self.add_default_info_extractors()

class Test(webapp2.RequestHandler):

    def get(self):

        video_id = 'm1ET6SEtwbc'

        ydl = SimpleYDL()
        info = ydl.extract_info(video_id, download=False)

        best_format = info['formats'][-1]

        stream_url = best_format['url']

        result = urlfetch.fetch(stream_url)
        response = {
            'url': stream_url,
            'status': result.status_code
        }

        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps(response))

####################################################################

app = webapp2.WSGIApplication([('/', Test)], debug=True)

I get a 403 with this video: m1ET6SEtwbc, and a 200 for this one: YP2BZc70pmQ (same thing with all formats).

I'm using __version__ = '2014.03.27.1' of youtube_dl

jaimeMF commented 10 years ago

Do you have any log produced by the app?, Have you tried setting the cachedir param and monkey patching?

If you can't reproduce it with my code I will close the issue.

jaimeMF commented 9 years ago

Closing due to lack of information.