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.

60 lines
1.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. import re
  5. class TwitCastingIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:[^/]+\.)?twitcasting\.tv/(?P<uploader_id>[^/]+)/movie/(?P<id>\d+)'
  7. _TEST = {
  8. 'url': 'https://twitcasting.tv/ivetesangalo/movie/2357609',
  9. 'md5': '745243cad58c4681dc752490f7540d7f',
  10. 'info_dict': {
  11. 'id': '2357609',
  12. 'ext': 'mp4',
  13. 'title': 'Recorded Live #2357609',
  14. 'uploader_id': 'ivetesangalo',
  15. 'description': "Moi! I'm live on TwitCasting from my iPhone.",
  16. 'thumbnail': r're:^https?://.*\.jpg$',
  17. },
  18. 'params': {
  19. 'skip_download': True,
  20. },
  21. }
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. uploader_id = mobj.group('uploader_id')
  26. webpage = self._download_webpage(url, video_id)
  27. title = self._html_search_regex(
  28. r'(?s)<[^>]+id=["\']movietitle[^>]+>(.+?)</',
  29. webpage, 'title', default=None) or self._html_search_meta(
  30. 'twitter:title', webpage, fatal=True)
  31. m3u8_url = self._search_regex(
  32. (r'data-movie-url=(["\'])(?P<url>(?:(?!\1).)+)\1',
  33. r'(["\'])(?P<url>http.+?\.m3u8.*?)\1'),
  34. webpage, 'm3u8 url', group='url')
  35. formats = self._extract_m3u8_formats(
  36. m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native',
  37. m3u8_id='hls')
  38. thumbnail = self._og_search_thumbnail(webpage)
  39. description = self._og_search_description(
  40. webpage, default=None) or self._html_search_meta(
  41. 'twitter:description', webpage)
  42. return {
  43. 'id': video_id,
  44. 'title': title,
  45. 'description': description,
  46. 'thumbnail': thumbnail,
  47. 'uploader_id': uploader_id,
  48. 'formats': formats,
  49. }