commonprotocols.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import urllib.parse
  2. from .common import InfoExtractor
  3. class RtmpIE(InfoExtractor):
  4. IE_DESC = False # Do not list
  5. _VALID_URL = r'(?i)rtmp[est]?://.+'
  6. _TESTS = [{
  7. 'url': 'rtmp://cp44293.edgefcs.net/ondemand?auth=daEcTdydfdqcsb8cZcDbAaCbhamacbbawaS-bw7dBb-bWG-GqpGFqCpNCnGoyL&aifp=v001&slist=public/unsecure/audio/2c97899446428e4301471a8cb72b4b97--audio--pmg-20110908-0900a_flv_aac_med_int.mp4',
  8. 'only_matching': True,
  9. }, {
  10. 'url': 'rtmp://edge.live.hitbox.tv/live/dimak',
  11. 'only_matching': True,
  12. }]
  13. def _real_extract(self, url):
  14. video_id = self._generic_id(url)
  15. title = self._generic_title(url)
  16. return {
  17. 'id': video_id,
  18. 'title': title,
  19. 'formats': [{
  20. 'url': url,
  21. 'ext': 'flv',
  22. 'format_id': urllib.parse.urlparse(url).scheme,
  23. }],
  24. }
  25. class MmsIE(InfoExtractor):
  26. IE_DESC = False # Do not list
  27. _VALID_URL = r'(?i)mms://.+'
  28. _TEST = {
  29. # Direct MMS link
  30. 'url': 'mms://kentro.kaist.ac.kr/200907/MilesReid(0709).wmv',
  31. 'info_dict': {
  32. 'id': 'MilesReid(0709)',
  33. 'ext': 'wmv',
  34. 'title': 'MilesReid(0709)',
  35. },
  36. 'params': {
  37. 'skip_download': True, # rtsp downloads, requiring mplayer or mpv
  38. },
  39. }
  40. def _real_extract(self, url):
  41. video_id = self._generic_id(url)
  42. title = self._generic_title(url)
  43. return {
  44. 'id': video_id,
  45. 'title': title,
  46. 'url': url,
  47. }
  48. class ViewSourceIE(InfoExtractor):
  49. IE_DESC = False
  50. _VALID_URL = r'view-source:(?P<url>.+)'
  51. _TEST = {
  52. 'url': 'view-source:https://www.youtube.com/watch?v=BaW_jenozKc',
  53. 'only_matching': True,
  54. }
  55. def _real_extract(self, url):
  56. return self.url_result(self._match_valid_url(url).group('url'))