utreon.py 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. dict_get,
  4. int_or_none,
  5. str_or_none,
  6. try_get,
  7. unified_strdate,
  8. url_or_none,
  9. )
  10. class UtreonIE(InfoExtractor):
  11. IE_NAME = 'playeur'
  12. _VALID_URL = r'https?://(?:www\.)?(?:utreon|playeur)\.com/v/(?P<id>[\w-]+)'
  13. _TESTS = [{
  14. 'url': 'https://utreon.com/v/z_I7ikQbuDw',
  15. 'info_dict': {
  16. 'id': 'z_I7ikQbuDw',
  17. 'ext': 'mp4',
  18. 'title': 'Freedom Friday meditation - Rising in the wind',
  19. 'description': 'md5:a9bf15a42434a062fe313b938343ad1b',
  20. 'uploader': 'Heather Dawn Elemental Health',
  21. 'thumbnail': r're:^https?://.+\.jpg',
  22. 'release_date': '20210723',
  23. 'duration': 586,
  24. },
  25. }, {
  26. 'url': 'https://utreon.com/v/jerJw5EOOVU',
  27. 'info_dict': {
  28. 'id': 'jerJw5EOOVU',
  29. 'ext': 'mp4',
  30. 'title': 'When I\'m alone, I love to reflect in peace, to make my dreams come true... [Quotes and Poems]',
  31. 'description': 'md5:4026aa3a2c10169c3649926ac8ef62b6',
  32. 'uploader': 'Frases e Poemas Quotes and Poems',
  33. 'thumbnail': r're:^https?://.+\.jpg',
  34. 'release_date': '20210723',
  35. 'duration': 60,
  36. },
  37. }, {
  38. 'url': 'https://utreon.com/v/C4ZxXhYBBmE',
  39. 'info_dict': {
  40. 'id': 'C4ZxXhYBBmE',
  41. 'ext': 'mp4',
  42. 'title': 'Biden’s Capital Gains Tax Rate to Test World’s Highest',
  43. 'description': 'md5:995aa9ad0733c0e5863ebdeff954f40e',
  44. 'uploader': 'Nomad Capitalist',
  45. 'thumbnail': r're:^https?://.+\.jpg',
  46. 'release_date': '20210723',
  47. 'duration': 884,
  48. },
  49. }, {
  50. 'url': 'https://utreon.com/v/Y-stEH-FBm8',
  51. 'info_dict': {
  52. 'id': 'Y-stEH-FBm8',
  53. 'ext': 'mp4',
  54. 'title': 'Creeper-Chan Pranks Steve! 💚 [MINECRAFT ANIME]',
  55. 'description': 'md5:7a48450b0d761b96dec194be0c5ecb5f',
  56. 'uploader': 'Merryweather Comics',
  57. 'thumbnail': r're:^https?://.+\.jpg',
  58. 'release_date': '20210718',
  59. 'duration': 151,
  60. },
  61. }, {
  62. 'url': 'https://playeur.com/v/Wzqp-UrxSeu',
  63. 'info_dict': {
  64. 'id': 'Wzqp-UrxSeu',
  65. 'ext': 'mp4',
  66. 'title': 'Update: Clockwork Basilisk Books on the Way!',
  67. 'description': 'md5:d9756b0b1884c904655b0e170d17cea5',
  68. 'uploader': 'Forgotten Weapons',
  69. 'release_date': '20240208',
  70. 'thumbnail': r're:^https?://.+\.jpg',
  71. 'duration': 262,
  72. },
  73. }]
  74. def _real_extract(self, url):
  75. video_id = self._match_id(url)
  76. json_data = self._download_json(
  77. 'https://api.playeur.com/v1/videos/' + video_id,
  78. video_id)
  79. videos_json = json_data['videos']
  80. formats = [{
  81. 'url': format_url,
  82. 'format_id': format_key.split('_')[1],
  83. 'height': int(format_key.split('_')[1][:-1]),
  84. } for format_key, format_url in videos_json.items() if url_or_none(format_url)]
  85. thumbnail = url_or_none(dict_get(json_data, ('cover_image_url', 'preview_image_url')))
  86. return {
  87. 'id': video_id,
  88. 'title': json_data['title'],
  89. 'formats': formats,
  90. 'description': str_or_none(json_data.get('description')),
  91. 'duration': int_or_none(json_data.get('duration')),
  92. 'uploader': str_or_none(try_get(json_data, lambda x: x['channel']['title'])),
  93. 'thumbnail': thumbnail,
  94. 'release_date': unified_strdate(json_data.get('published_datetime')),
  95. }