footyroom.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from .common import InfoExtractor
  2. from .streamable import StreamableIE
  3. class FootyRoomIE(InfoExtractor):
  4. _VALID_URL = r'https?://footyroom\.com/matches/(?P<id>\d+)'
  5. _TESTS = [{
  6. 'url': 'http://footyroom.com/matches/79922154/hull-city-vs-chelsea/review',
  7. 'info_dict': {
  8. 'id': '79922154',
  9. 'title': 'VIDEO Hull City 0 - 2 Chelsea',
  10. },
  11. 'playlist_count': 2,
  12. 'add_ie': [StreamableIE.ie_key()],
  13. }, {
  14. 'url': 'http://footyroom.com/matches/75817984/georgia-vs-germany/review',
  15. 'info_dict': {
  16. 'id': '75817984',
  17. 'title': 'VIDEO Georgia 0 - 2 Germany',
  18. },
  19. 'playlist_count': 1,
  20. 'add_ie': ['Playwire'],
  21. }]
  22. def _real_extract(self, url):
  23. playlist_id = self._match_id(url)
  24. webpage = self._download_webpage(url, playlist_id)
  25. playlist = self._parse_json(self._search_regex(
  26. r'DataStore\.media\s*=\s*([^;]+)', webpage, 'media data'),
  27. playlist_id)
  28. playlist_title = self._og_search_title(webpage)
  29. entries = []
  30. for video in playlist:
  31. payload = video.get('payload')
  32. if not payload:
  33. continue
  34. playwire_url = self._html_search_regex(
  35. r'data-config="([^"]+)"', payload,
  36. 'playwire url', default=None)
  37. if playwire_url:
  38. entries.append(self.url_result(self._proto_relative_url(
  39. playwire_url, 'http:'), 'Playwire'))
  40. streamable_url = StreamableIE._extract_url(payload)
  41. if streamable_url:
  42. entries.append(self.url_result(
  43. streamable_url, StreamableIE.ie_key()))
  44. return self.playlist_result(entries, playlist_id, playlist_title)