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.

61 lines
2.1 KiB

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