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.

66 lines
2.0 KiB

  1. import json
  2. import re
  3. from .common import InfoExtractor
  4. class TriluliluIE(InfoExtractor):
  5. _VALID_URL = r'(?x)(?:https?://)?(?:www\.)?trilulilu\.ro/video-(?P<category>[^/]+)/(?P<video_id>[^/]+)'
  6. _TEST = {
  7. u"url": u"http://www.trilulilu.ro/video-animatie/big-buck-bunny-1",
  8. u'file': u"big-buck-bunny-1.mp4",
  9. u'info_dict': {
  10. u"title": u"Big Buck Bunny",
  11. u"description": u":) pentru copilul din noi",
  12. },
  13. # Server ignores Range headers (--test)
  14. u"params": {
  15. u"skip_download": True
  16. }
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('video_id')
  21. webpage = self._download_webpage(url, video_id)
  22. title = self._og_search_title(webpage)
  23. thumbnail = self._og_search_thumbnail(webpage)
  24. description = self._og_search_description(webpage)
  25. log_str = self._search_regex(
  26. r'block_flash_vars[ ]=[ ]({[^}]+})', webpage, u'log info')
  27. log = json.loads(log_str)
  28. format_url = (u'http://fs%(server)s.trilulilu.ro/%(hash)s/'
  29. u'video-formats2' % log)
  30. format_doc = self._download_xml(
  31. format_url, video_id,
  32. note=u'Downloading formats',
  33. errnote=u'Error while downloading formats')
  34. video_url_template = (
  35. u'http://fs%(server)s.trilulilu.ro/stream.php?type=video'
  36. u'&source=site&hash=%(hash)s&username=%(userid)s&'
  37. u'key=ministhebest&format=%%s&sig=&exp=' %
  38. log)
  39. formats = [
  40. {
  41. 'format': fnode.text,
  42. 'url': video_url_template % fnode.text,
  43. 'ext': fnode.text.partition('-')[0]
  44. }
  45. for fnode in format_doc.findall('./formats/format')
  46. ]
  47. return {
  48. '_type': 'video',
  49. 'id': video_id,
  50. 'formats': formats,
  51. 'title': title,
  52. 'description': description,
  53. 'thumbnail': thumbnail,
  54. }