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.

78 lines
2.8 KiB

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