Merge remote-tracking branch 'rg3/master' into universalmusicfrance

This commit is contained in:
dabiboo 2015-09-22 09:15:05 +02:00
commit feb23fce08
4 changed files with 107 additions and 53 deletions

View File

@ -99,7 +99,7 @@ class TestAllURLsMatching(unittest.TestCase):
def test_keywords(self): def test_keywords(self):
self.assertMatch(':ytsubs', ['youtube:subscriptions']) self.assertMatch(':ytsubs', ['youtube:subscriptions'])
self.assertMatch(':ytsubscriptions', ['youtube:subscriptions']) self.assertMatch(':ytsubscriptions', ['youtube:subscriptions'])
self.assertMatch(':ythistory', ['youtube:history']) # self.assertMatch(':ythistory', ['youtube:history'])
self.assertMatch(':thedailyshow', ['ComedyCentralShows']) self.assertMatch(':thedailyshow', ['ComedyCentralShows'])
self.assertMatch(':tds', ['ComedyCentralShows']) self.assertMatch(':tds', ['ComedyCentralShows'])

View File

@ -809,6 +809,8 @@ from .youtube import (
YoutubeIE, YoutubeIE,
YoutubeChannelIE, YoutubeChannelIE,
YoutubeFavouritesIE, YoutubeFavouritesIE,
# disabled because it can wipe the watch history (see #6893)
# remember to uncomment test in test/test_all_urls when it's fixed
#YoutubeHistoryIE, #YoutubeHistoryIE,
YoutubePlaylistIE, YoutubePlaylistIE,
YoutubeRecommendedIE, YoutubeRecommendedIE,

View File

@ -16,12 +16,53 @@ from ..utils import (
class NFLIE(InfoExtractor): class NFLIE(InfoExtractor):
IE_NAME = 'nfl.com' IE_NAME = 'nfl.com'
_VALID_URL = r'''(?x)https?:// _VALID_URL = r'''(?x)
(?P<host>(?:www\.)?(?:nfl\.com|.*?\.clubs\.nfl\.com))/ https?://
(?P<host>
(?:www\.)?
(?:
(?:
nfl|
buffalobills|
miamidolphins|
patriots|
newyorkjets|
baltimoreravens|
bengals|
clevelandbrowns|
steelers|
houstontexans|
colts|
jaguars|
titansonline|
denverbroncos|
kcchiefs|
raiders|
chargers|
dallascowboys|
giants|
philadelphiaeagles|
redskins|
chicagobears|
detroitlions|
packers|
vikings|
atlantafalcons|
panthers|
neworleanssaints|
buccaneers|
azcardinals|
stlouisrams|
49ers|
seahawks
)\.com|
.+?\.clubs\.nfl\.com
)
)/
(?:.+?/)* (?:.+?/)*
(?P<id>(?:[a-z0-9]{16}|\w{8}\-(?:\w{4}\-){3}\w{12}))''' (?P<id>[^/#?&]+)
_TESTS = [ '''
{ _TESTS = [{
'url': 'http://www.nfl.com/videos/nfl-game-highlights/0ap3000000398478/Week-3-Redskins-vs-Eagles-highlights', 'url': 'http://www.nfl.com/videos/nfl-game-highlights/0ap3000000398478/Week-3-Redskins-vs-Eagles-highlights',
'md5': '394ef771ddcd1354f665b471d78ec4c6', 'md5': '394ef771ddcd1354f665b471d78ec4c6',
'info_dict': { 'info_dict': {
@ -33,8 +74,7 @@ class NFLIE(InfoExtractor):
'timestamp': 1411337580, 'timestamp': 1411337580,
'thumbnail': 're:^https?://.*\.jpg$', 'thumbnail': 're:^https?://.*\.jpg$',
} }
}, }, {
{
'url': 'http://prod.www.steelers.clubs.nfl.com/video-and-audio/videos/LIVE_Post_Game_vs_Browns/9d72f26a-9e2b-4718-84d3-09fb4046c266', 'url': 'http://prod.www.steelers.clubs.nfl.com/video-and-audio/videos/LIVE_Post_Game_vs_Browns/9d72f26a-9e2b-4718-84d3-09fb4046c266',
'md5': 'cf85bdb4bc49f6e9d3816d130c78279c', 'md5': 'cf85bdb4bc49f6e9d3816d130c78279c',
'info_dict': { 'info_dict': {
@ -46,8 +86,7 @@ class NFLIE(InfoExtractor):
'timestamp': 1388354455, 'timestamp': 1388354455,
'thumbnail': 're:^https?://.*\.jpg$', 'thumbnail': 're:^https?://.*\.jpg$',
} }
}, }, {
{
'url': 'http://www.nfl.com/news/story/0ap3000000467586/article/patriots-seahawks-involved-in-lategame-skirmish', 'url': 'http://www.nfl.com/news/story/0ap3000000467586/article/patriots-seahawks-involved-in-lategame-skirmish',
'info_dict': { 'info_dict': {
'id': '0ap3000000467607', 'id': '0ap3000000467607',
@ -57,12 +96,24 @@ class NFLIE(InfoExtractor):
'timestamp': 1422850320, 'timestamp': 1422850320,
'upload_date': '20150202', 'upload_date': '20150202',
}, },
}, {
'url': 'http://www.patriots.com/video/2015/09/18/10-days-gillette',
'md5': '4c319e2f625ffd0b481b4382c6fc124c',
'info_dict': {
'id': 'n-238346',
'ext': 'mp4',
'title': '10 Days at Gillette',
'description': 'md5:8cd9cd48fac16de596eadc0b24add951',
'timestamp': 1442618809,
'upload_date': '20150918',
}, },
{ }, {
'url': 'http://www.nfl.com/videos/nfl-network-top-ten/09000d5d810a6bd4/Top-10-Gutsiest-Performances-Jack-Youngblood', 'url': 'http://www.nfl.com/videos/nfl-network-top-ten/09000d5d810a6bd4/Top-10-Gutsiest-Performances-Jack-Youngblood',
'only_matching': True, 'only_matching': True,
} }, {
] 'url': 'http://www.buffalobills.com/video/videos/Rex_Ryan_Show_World_Wide_Rex/b1dcfab2-3190-4bb1-bfc0-d6e603d6601a',
'only_matching': True,
}]
@staticmethod @staticmethod
def prepend_host(host, url): def prepend_host(host, url):
@ -95,13 +146,14 @@ class NFLIE(InfoExtractor):
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
config_url = NFLIE.prepend_host(host, self._search_regex( config_url = NFLIE.prepend_host(host, self._search_regex(
r'(?:config|configURL)\s*:\s*"([^"]+)"', webpage, 'config URL', r'(?:(?:config|configURL)\s*:\s*|<nflcs:avplayer[^>]+data-config\s*=\s*)(["\'])(?P<config>.+?)\1',
default='static/content/static/config/video/config.json')) webpage, 'config URL', default='static/content/static/config/video/config.json',
group='config'))
# For articles, the id in the url is not the video id # For articles, the id in the url is not the video id
video_id = self._search_regex( video_id = self._search_regex(
r'contentId\s*:\s*"([^"]+)"', webpage, 'video id', default=video_id) r'(?:<nflcs:avplayer[^>]+data-contentId\s*=\s*|contentId\s*:\s*)(["\'])(?P<id>.+?)\1',
config = self._download_json(config_url, video_id, webpage, 'video id', default=video_id, group='id')
note='Downloading player config') config = self._download_json(config_url, video_id, 'Downloading player config')
url_template = NFLIE.prepend_host( url_template = NFLIE.prepend_host(
host, '{contentURLTemplate:}'.format(**config)) host, '{contentURLTemplate:}'.format(**config))
video_data = self._download_json( video_data = self._download_json(

View File

@ -619,7 +619,7 @@ def _create_http_connection(ydl_handler, http_class, is_https, *args, **kwargs):
# expected HTTP responses to meet HTTP/1.0 or later (see also # expected HTTP responses to meet HTTP/1.0 or later (see also
# https://github.com/rg3/youtube-dl/issues/6727) # https://github.com/rg3/youtube-dl/issues/6727)
if sys.version_info < (3, 0): if sys.version_info < (3, 0):
kwargs['strict'] = True kwargs[b'strict'] = True
hc = http_class(*args, **kwargs) hc = http_class(*args, **kwargs)
source_address = ydl_handler._params.get('source_address') source_address = ydl_handler._params.get('source_address')
if source_address is not None: if source_address is not None: