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.

40 lines
1.0 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import calendar
  4. import datetime
  5. import re
  6. from .common import InfoExtractor
  7. # audios on oe1.orf.at are only available for 7 days, so we can't
  8. # add tests.
  9. class OE1IE(InfoExtractor):
  10. IE_DESC = 'oe1.orf.at'
  11. _VALID_URL = r'http://oe1\.orf\.at/programm/(?P<id>[0-9]+)'
  12. def _real_extract(self, url):
  13. mobj = re.match(self._VALID_URL, url)
  14. show_id = mobj.group('id')
  15. data = self._download_json(
  16. 'http://oe1.orf.at/programm/%s/konsole' % show_id,
  17. show_id
  18. )
  19. timestamp = datetime.datetime.strptime('%s %s' % (
  20. data['item']['day_label'],
  21. data['item']['time']
  22. ), '%d.%m.%Y %H:%M')
  23. unix_timestamp = calendar.timegm(timestamp.utctimetuple())
  24. return {
  25. 'id': show_id,
  26. 'title': data['item']['title'],
  27. 'url': data['item']['url_stream'],
  28. 'ext': 'mp3',
  29. 'description': data['item'].get('info'),
  30. 'timestamp': unix_timestamp
  31. }