logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

pr0gramm.py (3643B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. import re
  5. from ..utils import (
  6. merge_dicts,
  7. )
  8. class Pr0grammStaticIE(InfoExtractor):
  9. # Possible urls:
  10. # https://pr0gramm.com/static/5466437
  11. _VALID_URL = r'https?://pr0gramm\.com/static/(?P<id>[0-9]+)'
  12. _TEST = {
  13. 'url': 'https://pr0gramm.com/static/5466437',
  14. 'md5': '52fa540d70d3edc286846f8ca85938aa',
  15. 'info_dict': {
  16. 'id': '5466437',
  17. 'ext': 'mp4',
  18. 'title': 'pr0gramm-5466437 by g11st',
  19. 'uploader': 'g11st',
  20. 'upload_date': '20221221',
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. # Fetch media sources
  27. entries = self._parse_html5_media_entries(url, webpage, video_id)
  28. media_info = entries[0]
  29. # this raises if there are no formats
  30. self._sort_formats(media_info.get('formats') or [])
  31. # Fetch author
  32. uploader = self._html_search_regex(r'by\W+([\w-]+)\W+', webpage, 'uploader')
  33. # Fetch approx upload timestamp from filename
  34. # Have None-defaults in case the extraction fails
  35. uploadDay = None
  36. uploadMon = None
  37. uploadYear = None
  38. uploadTimestr = None
  39. # (//img.pr0gramm.com/2022/12/21/62ae8aa5e2da0ebf.mp4)
  40. m = re.search(r'//img\.pr0gramm\.com/(?P<year>[\d]+)/(?P<mon>[\d]+)/(?P<day>[\d]+)/\w+\.\w{,4}', webpage)
  41. if (m):
  42. # Up to a day of accuracy should suffice...
  43. uploadDay = m.groupdict().get('day')
  44. uploadMon = m.groupdict().get('mon')
  45. uploadYear = m.groupdict().get('year')
  46. uploadTimestr = uploadYear + uploadMon + uploadDay
  47. return merge_dicts({
  48. 'id': video_id,
  49. 'title': 'pr0gramm-%s%s' % (video_id, (' by ' + uploader) if uploader else ''),
  50. 'uploader': uploader,
  51. 'upload_date': uploadTimestr
  52. }, media_info)
  53. # This extractor is for the primary url (used for sharing, and appears in the
  54. # location bar) Since this page loads the DOM via JS, yt-dl can't find any
  55. # video information here. So let's redirect to a compatibility version of
  56. # the site, which does contain the <video>-element by itself, without requiring
  57. # js to be ran.
  58. class Pr0grammIE(InfoExtractor):
  59. # Possible urls:
  60. # https://pr0gramm.com/new/546637
  61. # https://pr0gramm.com/new/video/546637
  62. # https://pr0gramm.com/top/546637
  63. # https://pr0gramm.com/top/video/546637
  64. # https://pr0gramm.com/user/g11st/uploads/5466437
  65. # https://pr0gramm.com/user/froschler/dafur-ist-man-hier/5091290
  66. # https://pr0gramm.com/user/froschler/reinziehen-1elf/5232030
  67. # https://pr0gramm.com/user/froschler/1elf/5232030
  68. # https://pr0gramm.com/new/5495710:comment62621020 <- this is not the id!
  69. # https://pr0gramm.com/top/fruher war alles damals/5498175
  70. _VALID_URL = r'https?:\/\/pr0gramm\.com\/(?!static/\d+).+?\/(?P<id>[\d]+)(:|$)'
  71. _TEST = {
  72. 'url': 'https://pr0gramm.com/new/video/5466437',
  73. 'info_dict': {
  74. 'id': '5466437',
  75. 'ext': 'mp4',
  76. 'title': 'pr0gramm-5466437 by g11st',
  77. 'uploader': 'g11st',
  78. 'upload_date': '20221221',
  79. }
  80. }
  81. def _generic_title():
  82. return "oof"
  83. def _real_extract(self, url):
  84. video_id = self._match_id(url)
  85. return self.url_result(
  86. 'https://pr0gramm.com/static/' + video_id,
  87. video_id=video_id,
  88. ie=Pr0grammStaticIE.ie_key())