Remove player-url in tweakers.py
[youtube-dl] / youtube_dl / extractor / tweakers.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class TweakersIE(InfoExtractor):
10     _VALID_URL = r'https?://tweakers\.net/video/(?P<id>[0-9]+).*'
11     _TEST = {
12         'url': 'https://tweakers.net/video/9926/new-nintendo-3ds-xl-op-alle-fronten-beter.html',
13         'md5': 'f7f7f3027166a7f32f024b4ae6571ced',
14         'info_dict': {
15             'id': '9926',
16             'ext': 'mp4',
17             'title': 'New-Nintendo-3Ds-Xl-Op-Alle-Fronten-Beter',
18             # TODO more properties, either as:
19             # * A value
20             # * MD5 checksum; start the string with md5:
21             # * A regular expression; start the string with re:
22             # * Any Python type (for example int or float)
23         }
24     }
25
26     def _real_extract(self, url):
27         splitted_url = re.split('.html|/', url)
28         del splitted_url[-1]  # To remove extra '/' at the end
29         video_id = splitted_url[4]
30         title = splitted_url[5].title()  # Retrieve title for URL and capitalize
31         splitted_url[3] = splitted_url[3] + '/player'  # Add /player to get the player page
32         player_url = '/'.join(splitted_url) + '.html'
33         player_page = self._download_webpage(player_url, video_id)
34
35         return {
36             'id': video_id,
37             'ext': 'mp4',
38             'title': title,
39             'url': re.findall('http.*mp4', player_page)[0],
40         }