Merge remote-tracking branch 'Dineshs91/f4m-2.0'
[youtube-dl] / youtube_dl / extractor / vh1.py
1 from __future__ import unicode_literals
2
3 from .mtv import MTVIE
4
5 import re
6 from ..utils import fix_xml_ampersands
7
8
9 class VH1IE(MTVIE):
10     IE_NAME = 'vh1.com'
11     _FEED_URL = 'http://www.vh1.com/player/embed/AS3/fullepisode/rss/'
12     _TESTS = [{
13         'url': 'http://www.vh1.com/video/metal-evolution/full-episodes/progressive-metal/1678612/playlist.jhtml',
14         'playlist': [
15             {
16                 'md5': '7827a7505f59633983165bbd2c119b52',
17                 'info_dict': {
18                     'id': '731565',
19                     'ext': 'mp4',
20                     'title': 'Metal Evolution: Ep. 11 Act 1',
21                     'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 12 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.'
22                 }
23             },
24             {
25                 'md5': '34fb4b7321c546b54deda2102a61821f',
26                 'info_dict': {
27                     'id': '731567',
28                     'ext': 'mp4',
29                     'title': 'Metal Evolution: Ep. 11 Act 2',
30                     'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 11 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.'
31                 }
32             },
33             {
34                 'md5': '813f38dba4c1b8647196135ebbf7e048',
35                 'info_dict': {
36                     'id': '731568',
37                     'ext': 'mp4',
38                     'title': 'Metal Evolution: Ep. 11 Act 3',
39                     'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 11 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.'
40                 }
41             },
42             {
43                 'md5': '51adb72439dfaed11c799115d76e497f',
44                 'info_dict': {
45                     'id': '731569',
46                     'ext': 'mp4',
47                     'title': 'Metal Evolution: Ep. 11 Act 4',
48                     'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 11 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.'
49                 }
50             },
51             {
52                 'md5': '93d554aaf79320703b73a95288c76a6e',
53                 'info_dict': {
54                     'id': '731570',
55                     'ext': 'mp4',
56                     'title': 'Metal Evolution: Ep. 11 Act 5',
57                     'description': 'Many rock academics have proclaimed that the truly progressive musicianship of the last 20 years has been found right here in the world of heavy metal, rather than obvious locales such as jazz, fusion or progressive rock. It stands to reason then, that much of this jaw-dropping virtuosity occurs within what\'s known as progressive metal, a genre that takes root with the likes of Rush in the \'70s, Queensryche and Fates Warning in the \'80s, and Dream Theater in the \'90s. Since then, the genre has exploded with creativity, spawning mind-bending, genre-defying acts such as Tool, Mastodon, Coheed And Cambria, Porcupine Tree, Meshuggah, A Perfect Circle and Opeth. Episode 11 looks at the extreme musicianship of these bands, as well as their often extreme literary prowess and conceptual strength, the end result being a rich level of respect and attention such challenging acts have brought upon the world of heavy metal, from a critical community usually dismissive of the form.'
58                 }
59             }
60         ],
61         'skip': 'Blocked outside the US',
62     }, {
63         # Clip
64         'url': 'http://www.vh1.com/video/misc/706675/metal-evolution-episode-1-pre-metal-show-clip.jhtml#id=1674118',
65         'md5': '7d67cf6d9cdc6b4f3d3ac97a55403844',
66         'info_dict': {
67             'id': '706675',
68             'ext': 'mp4',
69             'title': 'Metal Evolution: Episode 1 Pre-Metal Show Clip',
70             'description': 'The greatest documentary ever made about Heavy Metal begins as our host Sam Dunn travels the globe to seek out the origins and influences that helped create Heavy Metal. Sam speaks to legends like Kirk Hammett, Alice Cooper, Slash, Bill Ward, Geezer Butler, Tom Morello, Ace Frehley, Lemmy Kilmister, Dave Davies, and many many more. This episode is the prologue for the 11 hour series, and Sam goes back to the very beginning to reveal how Heavy Metal was created.'
71         },
72         'skip': 'Blocked outside the US',
73     }, {
74         # Short link
75         'url': 'http://www.vh1.com/video/play.jhtml?id=1678353',
76         'md5': '853192b87ad978732b67dd8e549b266a',
77         'info_dict': {
78             'id': '730355',
79             'ext': 'mp4',
80             'title': 'Metal Evolution: Episode 11 Progressive Metal Sneak',
81             'description': 'In Metal Evolution\'s finale sneak, Sam sits with Michael Giles of King Crimson and gets feedback from Metallica guitarist Kirk Hammett on why the group was influential.'
82         },
83         'skip': 'Blocked outside the US',
84     }, {
85         'url': 'http://www.vh1.com/video/macklemore-ryan-lewis/900535/cant-hold-us-ft-ray-dalton.jhtml',
86         'md5': 'b1bcb5b4380c9d7f544065589432dee7',
87         'info_dict': {
88             'id': '900535',
89             'ext': 'mp4',
90             'title': 'Macklemore & Ryan Lewis - "Can\'t Hold Us ft. Ray Dalton"',
91             'description': 'The Heist'
92         },
93         'skip': 'Blocked outside the US',
94     }]
95
96     _VALID_URL = r'''(?x)
97         https?://www\.vh1\.com/video/
98         (?:
99             .+?/full-episodes/.+?/(?P<playlist_id>[^/]+)/playlist\.jhtml
100         |
101             (?:
102             play.jhtml\?id=|
103             misc/.+?/.+?\.jhtml\#id=
104             )
105             (?P<video_id>[0-9]+)$
106         |
107             [^/]+/(?P<music_id>[0-9]+)/[^/]+?
108         )
109     '''
110
111     def _real_extract(self, url):
112         mobj = re.match(self._VALID_URL, url)
113         if mobj.group('music_id'):
114             id_field = 'vid'
115             video_id = mobj.group('music_id')
116         else:
117             video_id = mobj.group('playlist_id') or mobj.group('video_id')
118             id_field = 'id'
119         doc_url = '%s?%s=%s' % (self._FEED_URL, id_field, video_id)
120
121         idoc = self._download_xml(
122             doc_url, video_id,
123             'Downloading info', transform_source=fix_xml_ampersands)
124         return self.playlist_result(
125             [self._get_video_info(item) for item in idoc.findall('.//item')],
126             playlist_id=video_id,
127         )