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.

77 lines
2.7 KiB

  1. from __future__ import unicode_literals
  2. import random
  3. import re
  4. from .common import InfoExtractor
  5. class Laola1TvIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?laola1\.tv/(?P<lang>[a-z]+)-(?P<portal>[a-z]+)/.*?/(?P<id>[0-9]+)\.html'
  7. _TEST = {
  8. 'url': 'http://www.laola1.tv/de-de/live/bwf-bitburger-open-grand-prix-gold-court-1/250019.html',
  9. 'info_dict': {
  10. 'id': '250019',
  11. 'ext': 'mp4',
  12. 'title': 'Bitburger Open Grand Prix Gold - Court 1',
  13. 'categories': ['Badminton'],
  14. 'uploader': 'BWF - Badminton World Federation',
  15. 'is_live': True,
  16. },
  17. 'params': {
  18. 'skip_download': True,
  19. }
  20. }
  21. _BROKEN = True # Not really - extractor works fine, but f4m downloader does not support live streams yet.
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. lang = mobj.group('lang')
  26. portal = mobj.group('portal')
  27. webpage = self._download_webpage(url, video_id)
  28. iframe_url = self._search_regex(
  29. r'<iframe[^>]*?class="main_tv_player"[^>]*?src="([^"]+)"',
  30. webpage, 'iframe URL')
  31. iframe = self._download_webpage(
  32. iframe_url, video_id, note='Downloading iframe')
  33. flashvars_m = re.findall(
  34. r'flashvars\.([_a-zA-Z0-9]+)\s*=\s*"([^"]*)";', iframe)
  35. flashvars = dict((m[0], m[1]) for m in flashvars_m)
  36. xml_url = ('http://www.laola1.tv/server/hd_video.php?' +
  37. 'play=%s&partner=1&portal=%s&v5ident=&lang=%s' % (
  38. video_id, portal, lang))
  39. hd_doc = self._download_xml(xml_url, video_id)
  40. title = hd_doc.find('.//video/title').text
  41. flash_url = hd_doc.find('.//video/url').text
  42. categories = hd_doc.find('.//video/meta_sports').text.split(',')
  43. uploader = hd_doc.find('.//video/meta_organistation').text
  44. ident = random.randint(10000000, 99999999)
  45. token_url = '%s&ident=%s&klub=0&unikey=0&timestamp=%s&auth=%s' % (
  46. flash_url, ident, flashvars['timestamp'], flashvars['auth'])
  47. token_doc = self._download_xml(
  48. token_url, video_id, note='Downloading token')
  49. token_attrib = token_doc.find('.//token').attrib
  50. if token_attrib.get('auth') == 'blocked':
  51. raise ExtractorError('Token error: ' % token_attrib.get('comment'))
  52. video_url = '%s?hdnea=%s&hdcore=3.2.0' % (
  53. token_attrib['url'], token_attrib['auth'])
  54. return {
  55. 'id': video_id,
  56. 'is_live': True,
  57. 'title': title,
  58. 'url': video_url,
  59. 'uploader': uploader,
  60. 'categories': categories,
  61. 'ext': 'mp4',
  62. }