restudy.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class RestudyIE(InfoExtractor):
  5. _VALID_URL = r'https://www.restudy.dk/video/play/id/(?P<id>[0-9]+)'
  6. _TEST = {
  7. 'url': 'https://www.restudy.dk/video/play/id/1637',
  8. # MD5 sum of first 10241 bytes of the video file, as reported by
  9. # head -c 10241 Leiden-frosteffekt-1637.mp4 | md5sum
  10. 'md5': '4e755c4287f292a1fe5363834a683818',
  11. 'info_dict': {
  12. 'id': '1637',
  13. 'ext': 'mp4',
  14. 'title': 'Leiden-frosteffekt',
  15. }
  16. }
  17. def _real_extract(self, url):
  18. video_id = self._match_id(url)
  19. webpage = self._download_webpage(url, video_id)
  20. xml_url = (
  21. 'https://www.restudy.dk/awsmedia/SmilDirectory/video_%s.xml'
  22. % video_id)
  23. xml = self._download_webpage(xml_url, video_id)
  24. base = self._search_regex(
  25. r'<meta base="([^"]+)', xml, 'meta base')
  26. # TODO: Provide multiple video qualities instead of forcing highest
  27. filename = self._search_regex(
  28. r'<video src="mp4:([^"]+_high\.mp4)', xml, 'filename')
  29. url = '%s%s' % (base, filename)
  30. title = self._og_search_title(webpage)
  31. return {
  32. 'id': video_id,
  33. 'title': title,
  34. 'url': url,
  35. 'protocol': 'rtmp',
  36. }