mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 09:17:48 +00:00
Merge branch 'master' of github.com:rg3/youtube-dl
This commit is contained in:
commit
66398056f1
8 changed files with 127 additions and 27 deletions
|
@ -92,6 +92,8 @@ from .extractor import gen_extractors
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
from .YoutubeDL import YoutubeDL
|
from .YoutubeDL import YoutubeDL
|
||||||
from .postprocessor import (
|
from .postprocessor import (
|
||||||
|
AtomicParsleyPP,
|
||||||
|
FFmpegAudioFixPP,
|
||||||
FFmpegMetadataPP,
|
FFmpegMetadataPP,
|
||||||
FFmpegVideoConvertor,
|
FFmpegVideoConvertor,
|
||||||
FFmpegExtractAudioPP,
|
FFmpegExtractAudioPP,
|
||||||
|
@ -503,6 +505,8 @@ def parseOpts(overrideArguments=None):
|
||||||
help='do not overwrite post-processed files; the post-processed files are overwritten by default')
|
help='do not overwrite post-processed files; the post-processed files are overwritten by default')
|
||||||
postproc.add_option('--embed-subs', action='store_true', dest='embedsubtitles', default=False,
|
postproc.add_option('--embed-subs', action='store_true', dest='embedsubtitles', default=False,
|
||||||
help='embed subtitles in the video (only for mp4 videos)')
|
help='embed subtitles in the video (only for mp4 videos)')
|
||||||
|
postproc.add_option('--embed-thumbnail', action='store_true', dest='embedthumbnail', default=False,
|
||||||
|
help='embed thumbnail in the audio as cover art')
|
||||||
postproc.add_option('--add-metadata', action='store_true', dest='addmetadata', default=False,
|
postproc.add_option('--add-metadata', action='store_true', dest='addmetadata', default=False,
|
||||||
help='write metadata to the video file')
|
help='write metadata to the video file')
|
||||||
postproc.add_option('--xattrs', action='store_true', dest='xattrs', default=False,
|
postproc.add_option('--xattrs', action='store_true', dest='xattrs', default=False,
|
||||||
|
@ -808,6 +812,10 @@ def _real_main(argv=None):
|
||||||
ydl.add_post_processor(FFmpegEmbedSubtitlePP(subtitlesformat=opts.subtitlesformat))
|
ydl.add_post_processor(FFmpegEmbedSubtitlePP(subtitlesformat=opts.subtitlesformat))
|
||||||
if opts.xattrs:
|
if opts.xattrs:
|
||||||
ydl.add_post_processor(XAttrMetadataPP())
|
ydl.add_post_processor(XAttrMetadataPP())
|
||||||
|
if opts.embedthumbnail:
|
||||||
|
if not opts.addmetadata:
|
||||||
|
ydl.add_post_processor(FFmpegAudioFixPP())
|
||||||
|
ydl.add_post_processor(AtomicParsleyPP())
|
||||||
|
|
||||||
# Update version
|
# Update version
|
||||||
if opts.update_self:
|
if opts.update_self:
|
||||||
|
|
|
@ -140,7 +140,11 @@ class BrightcoveIE(InfoExtractor):
|
||||||
|
|
||||||
url_m = re.search(r'<meta\s+property="og:video"\s+content="(http://c.brightcove.com/[^"]+)"', webpage)
|
url_m = re.search(r'<meta\s+property="og:video"\s+content="(http://c.brightcove.com/[^"]+)"', webpage)
|
||||||
if url_m:
|
if url_m:
|
||||||
return [unescapeHTML(url_m.group(1))]
|
url = unescapeHTML(url_m.group(1))
|
||||||
|
# Some sites don't add it, we can't download with this url, for example:
|
||||||
|
# http://www.ktvu.com/videos/news/raw-video-caltrain-releases-video-of-man-almost/vCTZdY/
|
||||||
|
if 'playerKey' in url:
|
||||||
|
return [url]
|
||||||
|
|
||||||
matches = re.findall(
|
matches = re.findall(
|
||||||
r'''(?sx)<object
|
r'''(?sx)<object
|
||||||
|
|
|
@ -6,7 +6,6 @@ from .common import InfoExtractor
|
||||||
|
|
||||||
|
|
||||||
class FirstpostIE(InfoExtractor):
|
class FirstpostIE(InfoExtractor):
|
||||||
IE_NAME = 'Firstpost.com'
|
|
||||||
_VALID_URL = r'http://(?:www\.)?firstpost\.com/[^/]+/.*-(?P<id>[0-9]+)\.html'
|
_VALID_URL = r'http://(?:www\.)?firstpost\.com/[^/]+/.*-(?P<id>[0-9]+)\.html'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
|
@ -16,7 +15,6 @@ class FirstpostIE(InfoExtractor):
|
||||||
'id': '1025403',
|
'id': '1025403',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'India to launch indigenous aircraft carrier INS Vikrant today',
|
'title': 'India to launch indigenous aircraft carrier INS Vikrant today',
|
||||||
'description': 'Its flight deck is over twice the size of a football field, its power unit can light up the entire Kochi city and the cabling is enough to cover the distance between here to Delhi.',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,15 +22,26 @@ class FirstpostIE(InfoExtractor):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id = mobj.group('id')
|
video_id = mobj.group('id')
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
data = self._download_xml(
|
||||||
video_url = self._html_search_regex(
|
'http://www.firstpost.com/getvideoxml-%s.xml' % video_id, video_id,
|
||||||
r'<div.*?name="div_video".*?flashvars="([^"]+)">',
|
'Downloading video XML')
|
||||||
webpage, 'video URL')
|
|
||||||
|
item = data.find('./playlist/item')
|
||||||
|
thumbnail = item.find('./image').text
|
||||||
|
title = item.find('./title').text
|
||||||
|
|
||||||
|
formats = [
|
||||||
|
{
|
||||||
|
'url': details.find('./file').text,
|
||||||
|
'format_id': details.find('./label').text.strip(),
|
||||||
|
'width': int(details.find('./width').text.strip()),
|
||||||
|
'height': int(details.find('./height').text.strip()),
|
||||||
|
} for details in item.findall('./source/file_details') if details.find('./file').text
|
||||||
|
]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'url': video_url,
|
'title': title,
|
||||||
'title': self._og_search_title(webpage),
|
'thumbnail': thumbnail,
|
||||||
'description': self._og_search_description(webpage),
|
'formats': formats,
|
||||||
'thumbnail': self._og_search_thumbnail(webpage),
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,7 @@ class ProSiebenSat1IE(InfoExtractor):
|
||||||
_CLIPID_REGEXES = [
|
_CLIPID_REGEXES = [
|
||||||
r'"clip_id"\s*:\s+"(\d+)"',
|
r'"clip_id"\s*:\s+"(\d+)"',
|
||||||
r'clipid: "(\d+)"',
|
r'clipid: "(\d+)"',
|
||||||
|
r'clipId=(\d+)',
|
||||||
]
|
]
|
||||||
_TITLE_REGEXES = [
|
_TITLE_REGEXES = [
|
||||||
r'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>',
|
r'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>',
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import json
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
|
||||||
|
|
||||||
class WeiboIE(InfoExtractor):
|
class WeiboIE(InfoExtractor):
|
||||||
"""
|
"""
|
||||||
The videos in Weibo come from different sites, this IE just finds the link
|
The videos in Weibo come from different sites, this IE just finds the link
|
||||||
|
@ -13,16 +14,16 @@ class WeiboIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://video\.weibo\.com/v/weishipin/t_(?P<id>.+?)\.htm'
|
_VALID_URL = r'https?://video\.weibo\.com/v/weishipin/t_(?P<id>.+?)\.htm'
|
||||||
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
u'add_ie': ['Sina'],
|
'url': 'http://video.weibo.com/v/weishipin/t_zjUw2kZ.htm',
|
||||||
u'url': u'http://video.weibo.com/v/weishipin/t_zjUw2kZ.htm',
|
'info_dict': {
|
||||||
u'file': u'98322879.flv',
|
'id': '98322879',
|
||||||
u'info_dict': {
|
'ext': 'flv',
|
||||||
u'title': u'魔声耳机最新广告“All Eyes On Us”',
|
'title': '魔声耳机最新广告“All Eyes On Us”',
|
||||||
},
|
},
|
||||||
u'note': u'Sina video',
|
'params': {
|
||||||
u'params': {
|
'skip_download': True,
|
||||||
u'skip_download': True,
|
|
||||||
},
|
},
|
||||||
|
'add_ie': ['Sina'],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Additional example videos from different sites
|
# Additional example videos from different sites
|
||||||
|
@ -33,17 +34,16 @@ class WeiboIE(InfoExtractor):
|
||||||
mobj = re.match(self._VALID_URL, url, flags=re.VERBOSE)
|
mobj = re.match(self._VALID_URL, url, flags=re.VERBOSE)
|
||||||
video_id = mobj.group('id')
|
video_id = mobj.group('id')
|
||||||
info_url = 'http://video.weibo.com/?s=v&a=play_list&format=json&mix_video_id=t_%s' % video_id
|
info_url = 'http://video.weibo.com/?s=v&a=play_list&format=json&mix_video_id=t_%s' % video_id
|
||||||
info_page = self._download_webpage(info_url, video_id)
|
info = self._download_json(info_url, video_id)
|
||||||
info = json.loads(info_page)
|
|
||||||
|
|
||||||
videos_urls = map(lambda v: v['play_page_url'], info['result']['data'])
|
videos_urls = map(lambda v: v['play_page_url'], info['result']['data'])
|
||||||
#Prefer sina video since they have thumbnails
|
# Prefer sina video since they have thumbnails
|
||||||
videos_urls = sorted(videos_urls, key=lambda u: u'video.sina.com' in u)
|
videos_urls = sorted(videos_urls, key=lambda u: 'video.sina.com' in u)
|
||||||
player_url = videos_urls[-1]
|
player_url = videos_urls[-1]
|
||||||
m_sina = re.match(r'https?://video.sina.com.cn/v/b/(\d+)-\d+.html', player_url)
|
m_sina = re.match(r'https?://video\.sina\.com\.cn/v/b/(\d+)-\d+\.html',
|
||||||
|
player_url)
|
||||||
if m_sina is not None:
|
if m_sina is not None:
|
||||||
self.to_screen('Sina video detected')
|
self.to_screen('Sina video detected')
|
||||||
sina_id = m_sina.group(1)
|
sina_id = m_sina.group(1)
|
||||||
player_url = 'http://you.video.sina.com.cn/swf/quotePlayer.swf?vid=%s' % sina_id
|
player_url = 'http://you.video.sina.com.cn/swf/quotePlayer.swf?vid=%s' % sina_id
|
||||||
return self.url_result(player_url)
|
return self.url_result(player_url)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
|
||||||
|
from .atomicparsley import AtomicParsleyPP
|
||||||
from .ffmpeg import (
|
from .ffmpeg import (
|
||||||
|
FFmpegAudioFixPP,
|
||||||
FFmpegMergerPP,
|
FFmpegMergerPP,
|
||||||
FFmpegMetadataPP,
|
FFmpegMetadataPP,
|
||||||
FFmpegVideoConvertor,
|
FFmpegVideoConvertor,
|
||||||
|
@ -9,6 +11,8 @@ from .ffmpeg import (
|
||||||
from .xattrpp import XAttrMetadataPP
|
from .xattrpp import XAttrMetadataPP
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
'AtomicParsleyPP',
|
||||||
|
'FFmpegAudioFixPP',
|
||||||
'FFmpegMergerPP',
|
'FFmpegMergerPP',
|
||||||
'FFmpegMetadataPP',
|
'FFmpegMetadataPP',
|
||||||
'FFmpegVideoConvertor',
|
'FFmpegVideoConvertor',
|
||||||
|
|
56
youtube_dl/postprocessor/atomicparsley.py
Normal file
56
youtube_dl/postprocessor/atomicparsley.py
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from .common import PostProcessor
|
||||||
|
|
||||||
|
from ..utils import (
|
||||||
|
check_executable,
|
||||||
|
compat_urlretrieve,
|
||||||
|
encodeFilename,
|
||||||
|
PostProcessingError,
|
||||||
|
prepend_extension,
|
||||||
|
shell_quote
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class AtomicParsleyPPError(PostProcessingError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AtomicParsleyPP(PostProcessor):
|
||||||
|
def run(self, info):
|
||||||
|
if not check_executable('AtomicParsley', ['-v']):
|
||||||
|
raise AtomicParsleyPPError('AtomicParsley was not found. Please install.')
|
||||||
|
|
||||||
|
filename = info['filepath']
|
||||||
|
temp_filename = prepend_extension(filename, 'temp')
|
||||||
|
temp_thumbnail = prepend_extension(filename, 'thumb')
|
||||||
|
|
||||||
|
if not info.get('thumbnail'):
|
||||||
|
raise AtomicParsleyPPError('Thumbnail was not found. Nothing to do.')
|
||||||
|
|
||||||
|
compat_urlretrieve(info['thumbnail'], temp_thumbnail)
|
||||||
|
|
||||||
|
cmd = ['AtomicParsley', filename, '--artwork', temp_thumbnail, '-o', temp_filename]
|
||||||
|
|
||||||
|
self._downloader.to_screen('[atomicparsley] Adding thumbnail to "%s"' % filename)
|
||||||
|
|
||||||
|
if self._downloader.params.get('verbose', False):
|
||||||
|
self._downloader.to_screen('[debug] AtomicParsley command line: %s' % shell_quote(cmd))
|
||||||
|
|
||||||
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
stdout, stderr = p.communicate()
|
||||||
|
|
||||||
|
if p.returncode != 0:
|
||||||
|
msg = stderr.decode('utf-8', 'replace').strip()
|
||||||
|
raise AtomicParsleyPPError(msg)
|
||||||
|
|
||||||
|
os.remove(encodeFilename(filename))
|
||||||
|
os.remove(encodeFilename(temp_thumbnail))
|
||||||
|
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||||
|
|
||||||
|
return True, info
|
|
@ -464,7 +464,11 @@ class FFmpegMetadataPP(FFmpegPostProcessor):
|
||||||
filename = info['filepath']
|
filename = info['filepath']
|
||||||
temp_filename = prepend_extension(filename, 'temp')
|
temp_filename = prepend_extension(filename, 'temp')
|
||||||
|
|
||||||
options = ['-c', 'copy']
|
if info['ext'] == u'm4a':
|
||||||
|
options = ['-vn', '-acodec', 'copy']
|
||||||
|
else:
|
||||||
|
options = ['-c', 'copy']
|
||||||
|
|
||||||
for (name, value) in metadata.items():
|
for (name, value) in metadata.items():
|
||||||
options.extend(['-metadata', '%s=%s' % (name, value)])
|
options.extend(['-metadata', '%s=%s' % (name, value)])
|
||||||
|
|
||||||
|
@ -483,3 +487,17 @@ class FFmpegMergerPP(FFmpegPostProcessor):
|
||||||
self.run_ffmpeg_multiple_files(info['__files_to_merge'], filename, args)
|
self.run_ffmpeg_multiple_files(info['__files_to_merge'], filename, args)
|
||||||
return True, info
|
return True, info
|
||||||
|
|
||||||
|
|
||||||
|
class FFmpegAudioFixPP(FFmpegPostProcessor):
|
||||||
|
def run(self, info):
|
||||||
|
filename = info['filepath']
|
||||||
|
temp_filename = prepend_extension(filename, 'temp')
|
||||||
|
|
||||||
|
options = ['-vn', '-acodec', 'copy']
|
||||||
|
self._downloader.to_screen(u'[ffmpeg] Fixing audio file "%s"' % filename)
|
||||||
|
self.run_ffmpeg(filename, temp_filename, options)
|
||||||
|
|
||||||
|
os.remove(encodeFilename(filename))
|
||||||
|
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||||
|
|
||||||
|
return True, info
|
||||||
|
|
Loading…
Reference in a new issue