You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.1 KiB

12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. RegexNotFoundError,
  7. unescapeHTML,
  8. )
  9. class JukeboxIE(InfoExtractor):
  10. _VALID_URL = r'^http://www\.jukebox?\..+?\/.+[,](?P<id>[a-z0-9\-]+)\.html'
  11. _TEST = {
  12. 'url': 'http://www.jukebox.es/kosheen/videoclip,pride,r303r.html',
  13. 'info_dict': {
  14. 'id': 'r303r',
  15. 'ext': 'flv',
  16. 'title': 'Kosheen-En Vivo Pride',
  17. 'uploader': 'Kosheen',
  18. },
  19. }
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. html = self._download_webpage(url, video_id)
  23. iframe_url = unescapeHTML(self._search_regex(r'<iframe .*src="([^"]*)"', html, 'iframe url'))
  24. iframe_html = self._download_webpage(iframe_url, video_id, 'Downloading iframe')
  25. if re.search(r'class="jkb_waiting"', iframe_html) is not None:
  26. raise ExtractorError('Video is not available(in your country?)!')
  27. self.report_extraction(video_id)
  28. try:
  29. video_url = self._search_regex(r'"config":{"file":"(?P<video_url>http:[^"]+\?mdtk=[0-9]+)"',
  30. iframe_html, 'video url')
  31. video_url = unescapeHTML(video_url).replace('\/', '/')
  32. except RegexNotFoundError:
  33. youtube_url = self._search_regex(
  34. r'config":{"file":"(http:\\/\\/www\.youtube\.com\\/watch\?v=[^"]+)"',
  35. iframe_html, 'youtube url')
  36. youtube_url = unescapeHTML(youtube_url).replace('\/', '/')
  37. self.to_screen('Youtube video detected')
  38. return self.url_result(youtube_url, ie='Youtube')
  39. title = self._html_search_regex(r'<h1 class="inline">([^<]+)</h1>',
  40. html, 'title')
  41. artist = self._html_search_regex(r'<span id="infos_article_artist">([^<]+)</span>',
  42. html, 'artist')
  43. return {
  44. 'id': video_id,
  45. 'url': video_url,
  46. 'title': artist + '-' + title,
  47. 'uploader': artist,
  48. }