seeker.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. get_element_by_class,
  5. strip_or_none,
  6. )
  7. class SeekerIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?seeker\.com/(?P<display_id>.*)-(?P<article_id>\d+)\.html'
  9. _TESTS = [{
  10. 'url': 'http://www.seeker.com/should-trump-be-required-to-release-his-tax-returns-1833805621.html',
  11. 'md5': '897d44bbe0d8986a2ead96de565a92db',
  12. 'info_dict': {
  13. 'id': 'Elrn3gnY',
  14. 'ext': 'mp4',
  15. 'title': 'Should Trump Be Required To Release His Tax Returns?',
  16. 'description': 'md5:41efa8cfa8d627841045eec7b018eb45',
  17. 'timestamp': 1490090165,
  18. 'upload_date': '20170321',
  19. }
  20. }, {
  21. 'url': 'http://www.seeker.com/changes-expected-at-zoos-following-recent-gorilla-lion-shootings-1834116536.html',
  22. 'playlist': [
  23. {
  24. 'md5': '0497b9f20495174be73ae136949707d2',
  25. 'info_dict': {
  26. 'id': 'FihYQ8AE',
  27. 'ext': 'mp4',
  28. 'title': 'The Pros & Cons Of Zoos',
  29. 'description': 'md5:d88f99a8ea8e7d25e6ff77f271b1271c',
  30. 'timestamp': 1490039133,
  31. 'upload_date': '20170320',
  32. },
  33. }
  34. ],
  35. 'info_dict': {
  36. 'id': '1834116536',
  37. 'title': 'After Gorilla Killing, Changes Ahead for Zoos',
  38. 'description': 'The largest association of zoos and others are hoping to learn from recent incidents that led to the shooting deaths of a gorilla and two lions.',
  39. },
  40. }]
  41. def _real_extract(self, url):
  42. display_id, article_id = self._match_valid_url(url).groups()
  43. webpage = self._download_webpage(url, display_id)
  44. entries = []
  45. for jwp_id in re.findall(r'data-video-id="([a-zA-Z0-9]{8})"', webpage):
  46. entries.append(self.url_result(
  47. 'jwplatform:' + jwp_id, 'JWPlatform', jwp_id))
  48. return self.playlist_result(
  49. entries, article_id,
  50. self._og_search_title(webpage),
  51. strip_or_none(get_element_by_class('subtitle__text', webpage)) or self._og_search_description(webpage))