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.

50 lines
1.6 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class FootyRoomIE(InfoExtractor):
  5. _VALID_URL = r'https?://footyroom\.com/(?P<id>[^/]+)'
  6. _TESTS = [{
  7. 'url': 'http://footyroom.com/schalke-04-0-2-real-madrid-2015-02/',
  8. 'info_dict': {
  9. 'id': 'schalke-04-0-2-real-madrid-2015-02',
  10. 'title': 'Schalke 04 0 – 2 Real Madrid',
  11. },
  12. 'playlist_count': 3,
  13. 'skip': 'Video for this match is not available',
  14. }, {
  15. 'url': 'http://footyroom.com/georgia-0-2-germany-2015-03/',
  16. 'info_dict': {
  17. 'id': 'georgia-0-2-germany-2015-03',
  18. 'title': 'Georgia 0 – 2 Germany',
  19. },
  20. 'playlist_count': 1,
  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(
  26. self._search_regex(
  27. r'VideoSelector\.load\((\[.+?\])\);', webpage, 'video selector'),
  28. playlist_id)
  29. playlist_title = self._og_search_title(webpage)
  30. entries = []
  31. for video in playlist:
  32. payload = video.get('payload')
  33. if not payload:
  34. continue
  35. playwire_url = self._search_regex(
  36. r'data-config="([^"]+)"', payload,
  37. 'playwire url', default=None)
  38. if playwire_url:
  39. entries.append(self.url_result(self._proto_relative_url(
  40. playwire_url, 'http:'), 'Playwire'))
  41. return self.playlist_result(entries, playlist_id, playlist_title)