twitcasting.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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?://(?:(?:www|ssl|en|pt|es|ja|ko)\.)?twitcasting\.tv/(?P<uploader_id>[^\/]+)/movie/(?P<video_id>[0-9]+)'
  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. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group('video_id')
  22. uploader_id = mobj.group('uploader_id')
  23. webpage = self._download_webpage(url, video_id)
  24. playlist_url = self._html_search_regex(r'(["\'])(?P<url>http.+?\.m3u8.*?)\1', webpage, name='playlist url', group='url')
  25. formats = self._extract_m3u8_formats(playlist_url, video_id, ext='mp4')
  26. thumbnail = self._og_search_thumbnail(webpage)
  27. title = self._html_search_meta('twitter:title', webpage)
  28. description = self._og_search_description(webpage) or self._html_search_meta('twitter:description', webpage)
  29. return{
  30. 'id': video_id,
  31. 'url': url,
  32. 'title': title,
  33. 'description': description,
  34. 'thumbnail': thumbnail,
  35. 'uploader_id': uploader_id,
  36. 'formats': formats,
  37. }