Merge remote-tracking branch 'ralfharing/vh1'
[youtube-dl] / youtube_dl / extractor / vh1.py
1 from .mtv import MTVIE
2 import re
3 from ..utils import fix_xml_ampersands
4
5 class VH1IE(MTVIE):
6     IE_NAME = u'vh1.com'
7     _FEED_URL = 'http://www.vh1.com/player/embed/AS3/fullepisode/rss/'
8
9     def _real_extract(self, url):
10         mobj = re.match(self._VALID_URL, url)
11         video_id = mobj.group('videoid')
12         idoc = self._download_xml(
13             self._FEED_URL + '?id=' + video_id, video_id,
14             'Downloading info', transform_source=fix_xml_ampersands)
15         return [self._get_video_info(item) for item in idoc.findall('.//item')]
16
17
18 class VH1EpisodeIE(VH1IE):
19     _VALID_URL = r'https?://www\.vh1\.com/video/.+?/full-episodes/.+?/(?P<videoid>[^/]+)/playlist\.jhtml'
20     _TESTS = [
21         {
22             u'url': u'http://www.vh1.com/video/metal-evolution/full-episodes/progressive-metal/1678612/playlist.jhtml',
23             u'playlist': [
24                 {
25                     u'info_dict': {
26                         u'id': u'731565',
27                         u'ext': u'mp4',
28                         u'title': u'Metal Evolution: Ep. 11 Act 1',
29                         u'description': u'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.'
30                     }
31                 },
32                 {
33                     u'info_dict': {
34                         u'id': u'731567',
35                         u'ext': u'mp4',
36                         u'title': u'Metal Evolution: Ep. 11 Act 2',
37                         u'description': u'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.'
38                     }
39                 },
40
41                 {
42                     u'info_dict': {
43                         u'id': u'731568',
44                         u'ext': u'mp4',
45                         u'title': u'Metal Evolution: Ep. 11 Act 3',
46                         u'description': u'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.'
47                     }
48                 },
49                 {
50                     u'info_dict': {
51                         u'id': u'731569',
52                         u'ext': u'mp4',
53                         u'title': u'Metal Evolution: Ep. 11 Act 4',
54                         u'description': u'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.'
55                     }
56                 },
57                 {
58                     u'info_dict': {
59                         u'id': u'731570',
60                         u'ext': u'mp4',
61                         u'title': u'Metal Evolution: Ep. 11 Act 5',
62                         u'description': u'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.'
63                     }
64                 }
65             ]
66         }
67     ]
68
69
70 class VH1ClipIE(VH1IE):
71     _VALID_URL = r'https?://www\.vh1\.com/video/misc/.+?/.+?\.jhtml#id=(?P<videoid>[^/]+)$'
72     _TESTS = [
73         {
74             u'url': u'http://www.vh1.com/video/misc/706675/metal-evolution-episode-1-pre-metal-show-clip.jhtml#id=1674118',
75             u'info_dict': {
76                 u'id': u'706675',
77                 u'ext': u'mp4',
78                 u'title': u'Metal Evolution: Episode 1 Pre-Metal Show Clip',
79                 u'description': u'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.'
80             }
81         }
82     ]
83
84
85 class VH1ShortUrlIE(VH1IE):
86     _VALID_URL = r'https?://www\.vh1\.com/video/play.jhtml\?id=(?P<videoid>[^/]+)$'
87     _TESTS = [
88         {
89             u'url': u'http://www.vh1.com/video/play.jhtml?id=1678353',
90             u'info_dict': {
91                 u'id': u'730355',
92                 u'ext': u'mp4',
93                 u'title': u'Metal Evolution: Episode 11 Progressive Metal Sneak',
94                 u'description': u'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.'
95             }
96         }
97     ]
98
99
100 class VH1MusicVideoIE(VH1IE):
101     _VALID_URL = r'https?://www\.vh1\.com/video/.+?/(?P<videoid>[^/]+)/.+?$'
102     _TESTS = [
103         {
104             u'url': u'http://www.vh1.com/video/macklemore-ryan-lewis/900535/cant-hold-us-ft-ray-dalton.jhtml',
105             u'info_dict': {
106                 u'id': u'900535',
107                 u'ext': u'mp4',
108                 u'title': u'Macklemore & Ryan Lewis - "Can\'t Hold Us ft. Ray Dalton"',
109                 u'description': u'The Heist'
110             }
111         }
112     ]
113
114     def _real_extract(self, url):
115         mobj = re.match(self._VALID_URL, url)
116         video_id = mobj.group('videoid')
117         # difference from VH1IE._real_extract() is "vid" param instead of "id"
118         idoc = self._download_xml(
119             self._FEED_URL + '?vid=' + video_id, video_id,
120             'Downloading info', transform_source=fix_xml_ampersands)
121         return [self._get_video_info(item) for item in idoc.findall('.//item')]