You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import remove_end
  6. class TwentyMinutenIE(InfoExtractor):
  7. IE_NAME = '20min'
  8. _VALID_URL = r'https?://(?:www\.)?20min\.ch/(?:videotv/*\?.*\bvid=(?P<id>\d+)|(?:[^/]+/)*(?P<display_id>[^/#?]+))'
  9. _TESTS = [{
  10. # regular video
  11. 'url': 'http://www.20min.ch/videotv/?vid=469148&cid=2',
  12. 'md5': 'b52d6bc6ea6398e6a38f12cfd418149c',
  13. 'info_dict': {
  14. 'id': '469148',
  15. 'ext': 'flv',
  16. 'title': '85 000 Franken für 15 perfekte Minuten',
  17. 'description': 'Was die Besucher vom Silvesterzauber erwarten können. (Video: Alice Grosjean/Murat Temel)',
  18. 'thumbnail': 'http://thumbnails.20min-tv.ch/server063/469148/frame-72-469148.jpg'
  19. }
  20. }, {
  21. # news article with video
  22. 'url': 'http://www.20min.ch/schweiz/news/story/-Wir-muessen-mutig-nach-vorne-schauen--22050469',
  23. 'md5': 'cd4cbb99b94130cff423e967cd275e5e',
  24. 'info_dict': {
  25. 'id': '469408',
  26. 'display_id': '-Wir-muessen-mutig-nach-vorne-schauen--22050469',
  27. 'ext': 'flv',
  28. 'title': '«Wir müssen mutig nach vorne schauen»',
  29. 'description': 'Kein Land sei innovativer als die Schweiz, sagte Johann Schneider-Ammann in seiner Neujahrsansprache. Das Land müsse aber seine Hausaufgaben machen.',
  30. 'thumbnail': 'http://www.20min.ch/images/content/2/2/0/22050469/10/teaserbreit.jpg'
  31. }
  32. }, {
  33. 'url': 'http://www.20min.ch/videotv/?cid=44&vid=468738',
  34. 'only_matching': True,
  35. }, {
  36. 'url': 'http://www.20min.ch/ro/sortir/cinema/story/Grandir-au-bahut--c-est-dur-18927411',
  37. 'only_matching': True,
  38. }]
  39. def _real_extract(self, url):
  40. mobj = re.match(self._VALID_URL, url)
  41. video_id = mobj.group('id')
  42. display_id = mobj.group('display_id') or video_id
  43. webpage = self._download_webpage(url, display_id)
  44. title = self._html_search_regex(
  45. r'<h1>.*?<span>(.+?)</span></h1>',
  46. webpage, 'title', default=None)
  47. if not title:
  48. title = remove_end(re.sub(
  49. r'^20 [Mm]inuten.*? -', '', self._og_search_title(webpage)), ' - News')
  50. if not video_id:
  51. video_id = self._search_regex(
  52. r'"file\d?"\s*,\s*\"(\d+)', webpage, 'video id')
  53. description = self._html_search_meta(
  54. 'description', webpage, 'description')
  55. thumbnail = self._og_search_thumbnail(webpage)
  56. return {
  57. 'id': video_id,
  58. 'display_id': display_id,
  59. 'url': 'http://speed.20min-tv.ch/%sm.flv' % video_id,
  60. 'title': title,
  61. 'description': description,
  62. 'thumbnail': thumbnail,
  63. }