ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.94k stars 10.01k forks source link

I get an error when using the software with php! (2015.08.09 version) #6535

Closed ghost closed 9 years ago

ghost commented 9 years ago

I'm using youtube-dl version 2015.08.09 Process is going smoothly via SSH but I get an error when I try the following code in PHP.

I use this php code:

echo system("youtube-dl --extract-audio --audio-format mp3 -o \"/var/www/vhosts/my_site/my_downloads/%(id)s.%(ext)s\" -v https://www.youtube.com/watch?v=VIDEO_ID 2>&1");

HTML output:

[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'--extract-audio', u'--audio-format', u'mp3', u'-o', u'/var/www/vhosts/my_site/my_downloads_folder/%(id)s.%(ext)s', u'-v', u'https://www.youtube.com/watch?v=MmZAEMQzmfQ']
[debug] Encodings: locale ANSI_X3.4-1968, fs ANSI_X3.4-1968, out None, pref ANSI_X3.4-1968
[debug] youtube-dl version 2015.08.09
[debug] Python version 2.6.6 - Linux-2.6.32-504.30.3.el6.x86_64-x86_64-with-centos-6.6-Final
[debug] exe versions: ffmpeg 2.2.1, ffprobe 2.2.1
[debug] Proxy map: {}
[youtube] MmZAEMQzmfQ: Downloading webpage
[youtube] MmZAEMQzmfQ: Downloading video info webpage
[youtube] MmZAEMQzmfQ: Extracting video information
[youtube] {22} signature length 40.42, html5 player new
[youtube] {43} signature length 40.42, html5 player new
[youtube] {18} signature length 40.42, html5 player new
[youtube] {5} signature length 40.42, html5 player new
[youtube] {36} signature length 40.42, html5 player new
[youtube] {17} signature length 40.42, html5 player new
[youtube] {136} signature length 40.42, html5 player new
[youtube] {247} signature length 40.42, html5 player new
[youtube] {135} signature length 40.42, html5 player new
[youtube] {244} signature length 40.42, html5 player new
[youtube] {134} signature length 40.42, html5 player new
[youtube] {243} signature length 40.42, html5 player new
[youtube] {133} signature length 40.42, html5 player new
[youtube] {242} signature length 40.42, html5 player new
[youtube] {160} signature length 40.42, html5 player new
[youtube] {140} signature length 40.42, html5 player new
[youtube] {171} signature length 40.42, html5 player new
[youtube] MmZAEMQzmfQ: Downloading DASH manifest
WARNING: [youtube] MmZAEMQzmfQ: Skipping DASH manifest: ExtractorError(u'Could not download DASH manifest: HTTP Error 403: Forbidden (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.',)
[debug] Invoking downloader on u'https://r3---sn-8pgbpohxqp5-ac5e.googlevideo.com/videoplayback?upn=4VnNBKrd6VQ&mt=1439394125&mv=u&ms=au&fexp=9408710%2C9415365%2C9415485%2C9416023%2C9416126%2C9418153&source=youtube&mm=31&pl=24&mn=sn-8pgbpohxqp5-ac5e&id=o-AOPznZAyecjwyr8ZrCp4Qh5SHsCzcTvCn6mrVq8oQVfY&dur=171.525&requiressl=yes&ipbits=0&expire=1439415855&sparams=clen%2Cdur%2Cgir%2Cid%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&lmt=1417223201650493&sver=3&mime=audio%2Fmp4&key=yt5&itag=140&ip=MY_SERVER_IP&clen=2754389&gir=yes&keepalive=yes&signature=20DD10FA3A399479CC46BF0C1B1F64376E791557.67395004151BF88A2A65D932C2C5267A5C6E0C3B&ratebypass=yes'
ERROR: unable to download video data: HTTP Error 403: Forbidden
Traceback (most recent call last):
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1585, in process_info
    success = dl(filename, info_dict)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1527, in dl
    return fd.download(name, info)
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/common.py", line 342, in download
    return self.real_download(filename, info_dict)
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/http.py", line 60, in real_download
    data = self.ydl.urlopen(request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1860, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.6/urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
dstftw commented 9 years ago

Add --rm-cache-dir to your php script, run once then remove option. Duplicate of #6451.

ghost commented 9 years ago

Thank u Sergey!!! problem solved ! --rm-cache-dir :100: