mirror of
https://gitlab.com/ytdl-org/youtube-dl.git
synced 2026-01-24 00:00:10 -05:00
Compare commits
11 Commits
2011.09.18
...
2011.09.27
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1eff9ac0c5 | ||
|
|
54f329fe93 | ||
|
|
9baa2ef53b | ||
|
|
6bde5972c3 | ||
|
|
36f6cb369b | ||
|
|
b845d58b04 | ||
|
|
efb113c736 | ||
|
|
3ce59dae88 | ||
|
|
f0b0caa3fa | ||
|
|
58384838c3 | ||
|
|
abb870d1ad |
@@ -1 +1 @@
|
||||
2011.09.18c
|
||||
2011.09.27
|
||||
|
||||
10
README.md
10
README.md
@@ -33,13 +33,17 @@ which means you can modify it, redistribute it or use it however you like.
|
||||
-t, --title use title in file name
|
||||
-l, --literal use literal title in file name
|
||||
-A, --auto-number number downloaded files starting from 00000
|
||||
-o, --output TEMPLATE output filename template
|
||||
-o, --output TEMPLATE output filename template. Use %(stitle)s to get the
|
||||
title, %(uploader)s for the uploader name,
|
||||
%(autonumber)s to get an automatically incremented
|
||||
number, %(ext)s for the filename extension, and %%
|
||||
for a literal percent
|
||||
-a, --batch-file FILE file containing URLs to download ('-' for stdin)
|
||||
-w, --no-overwrites do not overwrite files
|
||||
-c, --continue resume partially downloaded files
|
||||
--no-continue do not resume partially downloaded files (restart
|
||||
from beginning)
|
||||
--cookies FILE file to dump cookie jar to
|
||||
--cookies FILE file to read cookies from and dump cookie jar in
|
||||
--no-part do not use .part files
|
||||
--no-mtime do not use the Last-modified header to set the file
|
||||
modification time
|
||||
@@ -73,7 +77,7 @@ which means you can modify it, redistribute it or use it however you like.
|
||||
### Post-processing Options:
|
||||
--extract-audio convert video files to audio-only files (requires
|
||||
ffmpeg and ffprobe)
|
||||
--audio-format FORMAT "best", "aac" or "mp3"; best by default
|
||||
--audio-format FORMAT "best", "aac", "vorbis" or "mp3"; best by default
|
||||
--audio-quality QUALITY ffmpeg audio bitrate specification, 128k by default
|
||||
-k, --keep-video keeps the video file on disk after the post-
|
||||
processing; the video is erased by default
|
||||
|
||||
123
youtube-dl
123
youtube-dl
@@ -15,7 +15,7 @@ __author__ = (
|
||||
)
|
||||
|
||||
__license__ = 'Public Domain'
|
||||
__version__ = '2011.09.18c'
|
||||
__version__ = '2011.09.27'
|
||||
|
||||
UPDATE_URL = 'https://raw.github.com/rg3/youtube-dl/master/youtube-dl'
|
||||
|
||||
@@ -766,7 +766,8 @@ class FileDownloader(object):
|
||||
try:
|
||||
infof = open(infofn, 'wb')
|
||||
try:
|
||||
json.dump(info_dict, infof)
|
||||
json_info_dict = dict((k,v) for k,v in info_dict.iteritems() if not k in ('urlhandle',))
|
||||
json.dump(json_info_dict, infof)
|
||||
finally:
|
||||
infof.close()
|
||||
except (OSError, IOError):
|
||||
@@ -905,6 +906,8 @@ class FileDownloader(object):
|
||||
while count <= retries:
|
||||
# Establish connection
|
||||
try:
|
||||
if count == 0 and 'urlhandle' in info_dict:
|
||||
data = info_dict['urlhandle']
|
||||
data = urllib2.urlopen(request)
|
||||
break
|
||||
except (urllib2.HTTPError, ), err:
|
||||
@@ -2432,7 +2435,7 @@ class YahooSearchIE(InfoExtractor):
|
||||
class YoutubePlaylistIE(InfoExtractor):
|
||||
"""Information Extractor for YouTube playlists."""
|
||||
|
||||
_VALID_URL = r'(?:http://)?(?:\w+\.)?youtube.com/(?:(?:view_play_list|my_playlists|artist|playlist)\?.*?(p|a|list)=|user/.*?/user/|p/|user/.*?#[pg]/c/)([0-9A-Za-z]+)(?:/.*?/([0-9A-Za-z_-]+))?.*'
|
||||
_VALID_URL = r'(?:https?://)?(?:\w+\.)?youtube\.com/(?:(?:view_play_list|my_playlists|artist|playlist)\?.*?(p|a|list)=|user/.*?/user/|p/|user/.*?#[pg]/c/)([0-9A-Za-z]+)(?:/.*?/([0-9A-Za-z_-]+))?.*'
|
||||
_TEMPLATE_URL = 'http://www.youtube.com/%s?%s=%s&page=%s&gl=US&hl=en'
|
||||
_VIDEO_INDICATOR = r'/watch\?v=(.+?)&'
|
||||
_MORE_PAGES_INDICATOR = r'(?m)>\s*Next\s*</a>'
|
||||
@@ -2506,7 +2509,7 @@ class YoutubePlaylistIE(InfoExtractor):
|
||||
class YoutubeUserIE(InfoExtractor):
|
||||
"""Information Extractor for YouTube users."""
|
||||
|
||||
_VALID_URL = r'(?:(?:(?:http://)?(?:\w+\.)?youtube.com/user/)|ytuser:)([A-Za-z0-9_-]+)'
|
||||
_VALID_URL = r'(?:(?:(?:https?://)?(?:\w+\.)?youtube\.com/user/)|ytuser:)([A-Za-z0-9_-]+)'
|
||||
_TEMPLATE_URL = 'http://gdata.youtube.com/feeds/api/users/%s'
|
||||
_GDATA_PAGE_SIZE = 50
|
||||
_GDATA_URL = 'http://gdata.youtube.com/feeds/api/users/%s/uploads?max-results=%d&start-index=%d'
|
||||
@@ -2594,7 +2597,7 @@ class YoutubeUserIE(InfoExtractor):
|
||||
class DepositFilesIE(InfoExtractor):
|
||||
"""Information extractor for depositfiles.com"""
|
||||
|
||||
_VALID_URL = r'(?:http://)?(?:\w+\.)?depositfiles.com/(?:../(?#locale))?files/(.+)'
|
||||
_VALID_URL = r'(?:http://)?(?:\w+\.)?depositfiles\.com/(?:../(?#locale))?files/(.+)'
|
||||
IE_NAME = u'DepositFiles'
|
||||
|
||||
def __init__(self, downloader=None):
|
||||
@@ -2671,7 +2674,7 @@ class DepositFilesIE(InfoExtractor):
|
||||
class FacebookIE(InfoExtractor):
|
||||
"""Information Extractor for Facebook"""
|
||||
|
||||
_VALID_URL = r'^(?:https?://)?(?:\w+\.)?facebook.com/video/video.php\?(?:.*?)v=(?P<ID>\d+)(?:.*)'
|
||||
_VALID_URL = r'^(?:https?://)?(?:\w+\.)?facebook\.com/video/video\.php\?(?:.*?)v=(?P<ID>\d+)(?:.*)'
|
||||
_LOGIN_URL = 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php&'
|
||||
_NETRC_MACHINE = 'facebook'
|
||||
_available_formats = ['highqual', 'lowqual']
|
||||
@@ -2895,7 +2898,11 @@ class BlipTVIE(InfoExtractor):
|
||||
|
||||
def report_extraction(self, file_id):
|
||||
"""Report information extraction."""
|
||||
self._downloader.to_screen(u'[blip.tv] %s: Extracting information' % file_id)
|
||||
self._downloader.to_screen(u'[%s] %s: Extracting information' % (self.IE_NAME, file_id))
|
||||
|
||||
def report_direct_download(self, title):
|
||||
"""Report information extraction."""
|
||||
self._downloader.to_screen(u'[%s] %s: Direct download detected' % (self.IE_NAME, title))
|
||||
|
||||
def _simplify_title(self, title):
|
||||
res = re.sub(ur'(?u)([^%s]+)' % simple_title_chars, ur'_', title)
|
||||
@@ -2915,43 +2922,64 @@ class BlipTVIE(InfoExtractor):
|
||||
json_url = url + cchar + 'skin=json&version=2&no_wrap=1'
|
||||
request = urllib2.Request(json_url)
|
||||
self.report_extraction(mobj.group(1))
|
||||
info = None
|
||||
try:
|
||||
json_code = urllib2.urlopen(request).read()
|
||||
urlh = urllib2.urlopen(request)
|
||||
if urlh.headers.get('Content-Type', '').startswith('video/'): # Direct download
|
||||
basename = url.split('/')[-1]
|
||||
title,ext = os.path.splitext(basename)
|
||||
ext = ext.replace('.', '')
|
||||
self.report_direct_download(title)
|
||||
info = {
|
||||
'id': title,
|
||||
'url': url,
|
||||
'title': title,
|
||||
'stitle': self._simplify_title(title),
|
||||
'ext': ext,
|
||||
'urlhandle': urlh
|
||||
}
|
||||
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
||||
self._downloader.trouble(u'ERROR: unable to download video info webpage: %s' % str(err))
|
||||
return
|
||||
try:
|
||||
json_data = json.loads(json_code)
|
||||
if 'Post' in json_data:
|
||||
data = json_data['Post']
|
||||
else:
|
||||
data = json_data
|
||||
if info is None: # Regular URL
|
||||
try:
|
||||
json_code = urlh.read()
|
||||
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
||||
self._downloader.trouble(u'ERROR: unable to read video info webpage: %s' % str(err))
|
||||
return
|
||||
|
||||
upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
|
||||
video_url = data['media']['url']
|
||||
umobj = re.match(self._URL_EXT, video_url)
|
||||
if umobj is None:
|
||||
raise ValueError('Can not determine filename extension')
|
||||
ext = umobj.group(1)
|
||||
try:
|
||||
json_data = json.loads(json_code)
|
||||
if 'Post' in json_data:
|
||||
data = json_data['Post']
|
||||
else:
|
||||
data = json_data
|
||||
|
||||
upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
|
||||
video_url = data['media']['url']
|
||||
umobj = re.match(self._URL_EXT, video_url)
|
||||
if umobj is None:
|
||||
raise ValueError('Can not determine filename extension')
|
||||
ext = umobj.group(1)
|
||||
|
||||
info = {
|
||||
'id': data['item_id'],
|
||||
'url': video_url,
|
||||
'uploader': data['display_name'],
|
||||
'upload_date': upload_date,
|
||||
'title': data['title'],
|
||||
'stitle': self._simplify_title(data['title']),
|
||||
'ext': ext,
|
||||
'format': data['media']['mimeType'],
|
||||
'thumbnail': data['thumbnailUrl'],
|
||||
'description': data['description'],
|
||||
'player_url': data['embedUrl']
|
||||
}
|
||||
except (ValueError,KeyError), err:
|
||||
self._downloader.trouble(u'ERROR: unable to parse video information: %s' % repr(err))
|
||||
return
|
||||
|
||||
self._downloader.increment_downloads()
|
||||
|
||||
info = {
|
||||
'id': data['item_id'],
|
||||
'url': video_url,
|
||||
'uploader': data['display_name'],
|
||||
'upload_date': upload_date,
|
||||
'title': data['title'],
|
||||
'stitle': self._simplify_title(data['title']),
|
||||
'ext': ext,
|
||||
'format': data['media']['mimeType'],
|
||||
'thumbnail': data['thumbnailUrl'],
|
||||
'description': data['description'],
|
||||
'player_url': data['embedUrl']
|
||||
}
|
||||
except (ValueError,KeyError), err:
|
||||
self._downloader.trouble(u'ERROR: unable to parse video information: %s' % repr(err))
|
||||
return
|
||||
self._downloader.increment_downloads()
|
||||
|
||||
try:
|
||||
self._downloader.process_info(info)
|
||||
@@ -3017,7 +3045,6 @@ class MyVideoIE(InfoExtractor):
|
||||
video_title = sanitize_title(video_title)
|
||||
|
||||
try:
|
||||
print(video_url)
|
||||
self._downloader.process_info({
|
||||
'id': video_id,
|
||||
'url': video_url,
|
||||
@@ -3176,7 +3203,7 @@ class ComedyCentralIE(InfoExtractor):
|
||||
class EscapistIE(InfoExtractor):
|
||||
"""Information extractor for The Escapist """
|
||||
|
||||
_VALID_URL = r'^(https?://)?(www\.)?escapistmagazine.com/videos/view/(?P<showname>[^/]+)/(?P<episode>[^/?]+)[/?]?.*$'
|
||||
_VALID_URL = r'^(https?://)?(www\.)?escapistmagazine\.com/videos/view/(?P<showname>[^/]+)/(?P<episode>[^/?]+)[/?]?.*$'
|
||||
IE_NAME = u'escapist'
|
||||
|
||||
def report_extraction(self, showName):
|
||||
@@ -3351,12 +3378,14 @@ class FFmpegExtractAudioPP(PostProcessor):
|
||||
|
||||
more_opts = []
|
||||
if self._preferredcodec == 'best' or self._preferredcodec == filecodec:
|
||||
if filecodec == 'aac' or filecodec == 'mp3':
|
||||
if filecodec in ['aac', 'mp3', 'vorbis']:
|
||||
# Lossless if possible
|
||||
acodec = 'copy'
|
||||
extension = filecodec
|
||||
if filecodec == 'aac':
|
||||
more_opts = ['-f', 'adts']
|
||||
if filecodec == 'vorbis':
|
||||
extension = 'ogg'
|
||||
else:
|
||||
# MP3 otherwise.
|
||||
acodec = 'libmp3lame'
|
||||
@@ -3366,13 +3395,15 @@ class FFmpegExtractAudioPP(PostProcessor):
|
||||
more_opts += ['-ab', self._preferredquality]
|
||||
else:
|
||||
# We convert the audio (lossy)
|
||||
acodec = {'mp3': 'libmp3lame', 'aac': 'aac'}[self._preferredcodec]
|
||||
acodec = {'mp3': 'libmp3lame', 'aac': 'aac', 'vorbis': 'libvorbis'}[self._preferredcodec]
|
||||
extension = self._preferredcodec
|
||||
more_opts = []
|
||||
if self._preferredquality is not None:
|
||||
more_opts += ['-ab', self._preferredquality]
|
||||
if self._preferredcodec == 'aac':
|
||||
more_opts += ['-f', 'adts']
|
||||
if self._preferredcodec == 'vorbis':
|
||||
extension = 'ogg'
|
||||
|
||||
(prefix, ext) = os.path.splitext(path)
|
||||
new_path = prefix + '.' + extension
|
||||
@@ -3572,7 +3603,7 @@ def parseOpts():
|
||||
action='store_true', dest='autonumber',
|
||||
help='number downloaded files starting from 00000', default=False)
|
||||
filesystem.add_option('-o', '--output',
|
||||
dest='outtmpl', metavar='TEMPLATE', help='output filename template')
|
||||
dest='outtmpl', metavar='TEMPLATE', help='output filename template. Use %(stitle)s to get the title, %(uploader)s for the uploader name, %(autonumber)s to get an automatically incremented number, %(ext)s for the filename extension, and %% for a literal percent')
|
||||
filesystem.add_option('-a', '--batch-file',
|
||||
dest='batchfile', metavar='FILE', help='file containing URLs to download (\'-\' for stdin)')
|
||||
filesystem.add_option('-w', '--no-overwrites',
|
||||
@@ -3583,7 +3614,7 @@ def parseOpts():
|
||||
action='store_false', dest='continue_dl',
|
||||
help='do not resume partially downloaded files (restart from beginning)')
|
||||
filesystem.add_option('--cookies',
|
||||
dest='cookiefile', metavar='FILE', help='file to dump cookie jar to')
|
||||
dest='cookiefile', metavar='FILE', help='file to read cookies from and dump cookie jar in')
|
||||
filesystem.add_option('--no-part',
|
||||
action='store_true', dest='nopart', help='do not use .part files', default=False)
|
||||
filesystem.add_option('--no-mtime',
|
||||
@@ -3600,7 +3631,7 @@ def parseOpts():
|
||||
postproc.add_option('--extract-audio', action='store_true', dest='extractaudio', default=False,
|
||||
help='convert video files to audio-only files (requires ffmpeg and ffprobe)')
|
||||
postproc.add_option('--audio-format', metavar='FORMAT', dest='audioformat', default='best',
|
||||
help='"best", "aac" or "mp3"; best by default')
|
||||
help='"best", "aac", "vorbis" or "mp3"; best by default')
|
||||
postproc.add_option('--audio-quality', metavar='QUALITY', dest='audioquality', default='128K',
|
||||
help='ffmpeg audio bitrate specification, 128k by default')
|
||||
postproc.add_option('-k', '--keep-video', action='store_true', dest='keepvideo', default=False,
|
||||
@@ -3734,7 +3765,7 @@ def main():
|
||||
except (TypeError, ValueError), err:
|
||||
parser.error(u'invalid playlist end number specified')
|
||||
if opts.extractaudio:
|
||||
if opts.audioformat not in ['best', 'aac', 'mp3']:
|
||||
if opts.audioformat not in ['best', 'aac', 'mp3', 'vorbis']:
|
||||
parser.error(u'invalid audio format specified')
|
||||
|
||||
# File downloader
|
||||
|
||||
Reference in New Issue
Block a user