Merge branch 'master' into rtmpdump
[youtube-dl] / youtube_dl / extractor / southparkstudios.py
1 import re
2
3 from .mtv import MTVIE, _media_xml_tag
4
5
6 class SouthParkStudiosIE(MTVIE):
7     IE_NAME = u'southparkstudios.com'
8     _VALID_URL = r'(https?://)?(www\.)?(?P<url>southparkstudios\.com/(clips|full-episodes)/(?P<id>.+?)(\?|#|$))'
9
10     _FEED_URL = 'http://www.southparkstudios.com/feeds/video-player/mrss'
11
12     # Overwrite MTVIE properties we don't want
13     _TESTS = [{
14         u'url': u'http://www.southparkstudios.com/clips/104437/bat-daded#tab=featured',
15         u'file': u'a7bff6c2-ed00-11e0-aca6-0026b9414f30.mp4',
16         u'info_dict': {
17             u'title': u'Bat Daded',
18             u'description': u'Randy disqualifies South Park by getting into a fight with Bat Dad.',
19         },
20     }]
21
22     def _get_thumbnail_url(self, uri, itemdoc):
23         search_path = '%s/%s' % (_media_xml_tag('group'), _media_xml_tag('thumbnail'))
24         thumb_node = itemdoc.find(search_path)
25         if thumb_node is None:
26             return None
27         else:
28             return thumb_node.attrib['url']
29
30     def _real_extract(self, url):
31         mobj = re.match(self._VALID_URL, url)
32         url = u'http://www.' + mobj.group(u'url')
33         video_id = mobj.group('id')
34         webpage = self._download_webpage(url, video_id)
35         mgid = self._search_regex(r'swfobject.embedSWF\(".*?(mgid:.*?)"',
36                                   webpage, u'mgid')
37         return self._get_videos_info(mgid)
38
39 class SouthparkDeIE(SouthParkStudiosIE):
40     IE_NAME = u'southpark.de'
41     _VALID_URL = r'(https?://)?(www\.)?(?P<url>southpark\.de/(clips|alle-episoden)/(?P<id>.+?)(\?|#|$))'
42     _FEED_URL = 'http://www.southpark.de/feeds/video-player/mrss/'
43
44     _TESTS = [{
45         u'url': u'http://www.southpark.de/clips/uygssh/the-government-wont-respect-my-privacy#tab=featured',
46         u'file': u'85487c96-b3b9-4e39-9127-ad88583d9bf2.mp4',
47         u'info_dict': {
48             u'title': u'The Government Won\'t Respect My Privacy',
49             u'description': u'Cartman explains the benefits of "Shitter" to Stan, Kyle and Craig.',
50         },
51     }]