newspicks.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import ExtractorError
  4. class NewsPicksIE(InfoExtractor):
  5. _VALID_URL = r'https?://newspicks\.com/movie-series/(?P<channel_id>\d+)\?movieId=(?P<id>\d+)'
  6. _TESTS = [{
  7. 'url': 'https://newspicks.com/movie-series/11?movieId=1813',
  8. 'info_dict': {
  9. 'id': '1813',
  10. 'title': '日本の課題を破壊せよ【ゲスト:成田悠輔】',
  11. 'description': 'md5:09397aad46d6ded6487ff13f138acadf',
  12. 'channel': 'HORIE ONE',
  13. 'channel_id': '11',
  14. 'release_date': '20220117',
  15. 'thumbnail': r're:https://.+jpg',
  16. 'ext': 'mp4',
  17. },
  18. }]
  19. def _real_extract(self, url):
  20. video_id, channel_id = self._match_valid_url(url).group('id', 'channel_id')
  21. webpage = self._download_webpage(url, video_id)
  22. entries = self._parse_html5_media_entries(
  23. url, webpage.replace('movie-for-pc', 'movie'), video_id, 'hls')
  24. if not entries:
  25. raise ExtractorError('No HTML5 media elements found')
  26. info = entries[0]
  27. title = self._html_search_meta('og:title', webpage, fatal=False)
  28. description = self._html_search_meta(
  29. ('og:description', 'twitter:title'), webpage, fatal=False)
  30. channel = self._html_search_regex(
  31. r'value="11".+?<div\s+class="title">(.+?)</div', webpage, 'channel name', fatal=False)
  32. if not title or not channel:
  33. title, channel = re.split(r'\s*|\s*', self._html_extract_title(webpage))
  34. release_date = self._search_regex(
  35. r'<span\s+class="on-air-date">\s*(\d+)年(\d+)月(\d+)日\s*</span>',
  36. webpage, 'release date', fatal=False, group=(1, 2, 3))
  37. info.update({
  38. 'id': video_id,
  39. 'title': title,
  40. 'description': description,
  41. 'channel': channel,
  42. 'channel_id': channel_id,
  43. 'release_date': ('%04d%02d%02d' % tuple(map(int, release_date))) if release_date else None,
  44. })
  45. return info