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.

65 lines
2.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from .fivemin import FiveMinIE
  5. class AolIE(InfoExtractor):
  6. IE_NAME = 'on.aol.com'
  7. _VALID_URL = r'''(?x)
  8. (?:
  9. aol-video:|
  10. http://on\.aol\.com/
  11. (?:
  12. video/.*-|
  13. playlist/(?P<playlist_display_id>[^/?#]+?)-(?P<playlist_id>[0-9]+)[?#].*_videoid=
  14. )
  15. )
  16. (?P<id>[0-9]+)
  17. (?:$|\?)
  18. '''
  19. _TEST = {
  20. 'url': 'http://on.aol.com/video/u-s--official-warns-of-largest-ever-irs-phone-scam-518167793?icid=OnHomepageC2Wide_MustSee_Img',
  21. 'md5': '18ef68f48740e86ae94b98da815eec42',
  22. 'info_dict': {
  23. 'id': '518167793',
  24. 'ext': 'mp4',
  25. 'title': 'U.S. Official Warns Of \'Largest Ever\' IRS Phone Scam',
  26. },
  27. 'add_ie': ['FiveMin'],
  28. }
  29. def _real_extract(self, url):
  30. mobj = re.match(self._VALID_URL, url)
  31. video_id = mobj.group('id')
  32. playlist_id = mobj.group('playlist_id')
  33. if playlist_id and not self._downloader.params.get('noplaylist'):
  34. self.to_screen('Downloading playlist %s - add --no-playlist to just download video %s' % (playlist_id, video_id))
  35. webpage = self._download_webpage(url, playlist_id)
  36. title = self._html_search_regex(
  37. r'<h1 class="video-title[^"]*">(.+?)</h1>', webpage, 'title')
  38. playlist_html = self._search_regex(
  39. r"(?s)<ul\s+class='video-related[^']*'>(.*?)</ul>", webpage,
  40. 'playlist HTML')
  41. entries = [{
  42. '_type': 'url',
  43. 'url': 'aol-video:%s' % m.group('id'),
  44. 'ie_key': 'Aol',
  45. } for m in re.finditer(
  46. r"<a\s+href='.*videoid=(?P<id>[0-9]+)'\s+class='video-thumb'>",
  47. playlist_html)]
  48. return {
  49. '_type': 'playlist',
  50. 'id': playlist_id,
  51. 'display_id': mobj.group('playlist_display_id'),
  52. 'title': title,
  53. 'entries': entries,
  54. }
  55. return FiveMinIE._build_result(video_id)