onefootball.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from .common import InfoExtractor
  2. from .jwplatform import JWPlatformIE
  3. from ..utils import make_archive_id
  4. class OneFootballIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?onefootball\.com/[a-z]{2}/video/[^/&?#]+-(?P<id>\d+)'
  6. _TESTS = [{
  7. 'url': 'https://onefootball.com/en/video/highlights-fc-zuerich-3-3-fc-basel-34012334',
  8. 'info_dict': {
  9. 'id': 'Y2VtcWAT',
  10. 'ext': 'mp4',
  11. 'title': 'Highlights: FC Zürich 3-3 FC Basel',
  12. 'description': 'md5:33d9855cb790702c4fe42a513700aba8',
  13. 'thumbnail': 'https://cdn.jwplayer.com/v2/media/Y2VtcWAT/poster.jpg?width=720',
  14. 'timestamp': 1635874895,
  15. 'upload_date': '20211102',
  16. 'duration': 375.0,
  17. 'tags': ['Football', 'Soccer', 'OneFootball'],
  18. '_old_archive_ids': ['onefootball 34012334'],
  19. },
  20. 'params': {'skip_download': True},
  21. 'expected_warnings': ['Failed to download m3u8 information'],
  22. }, {
  23. 'url': 'https://onefootball.com/en/video/klopp-fumes-at-var-decisions-in-west-ham-defeat-34041020',
  24. 'info_dict': {
  25. 'id': 'leVJrMho',
  26. 'ext': 'mp4',
  27. 'title': 'Klopp fumes at VAR decisions in West Ham defeat',
  28. 'description': 'md5:9c50371095a01ad3f63311c73d8f51a5',
  29. 'thumbnail': 'https://cdn.jwplayer.com/v2/media/leVJrMho/poster.jpg?width=720',
  30. 'timestamp': 1636315232,
  31. 'upload_date': '20211107',
  32. 'duration': 93.0,
  33. 'tags': ['Football', 'Soccer', 'OneFootball'],
  34. '_old_archive_ids': ['onefootball 34041020'],
  35. },
  36. 'params': {'skip_download': True},
  37. }]
  38. def _real_extract(self, url):
  39. video_id = self._match_id(url)
  40. webpage = self._download_webpage(url, video_id)
  41. data_json = self._search_json_ld(webpage, video_id, fatal=False)
  42. data_json.pop('url', None)
  43. m3u8_url = self._html_search_regex(r'(https://cdn\.jwplayer\.com/manifests/\w+\.m3u8)', webpage, 'm3u8_url')
  44. return self.url_result(
  45. m3u8_url, JWPlatformIE, video_id, _old_archive_ids=[make_archive_id(self, video_id)],
  46. **data_json, url_transparent=True)