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.

59 lines
2.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. unified_strdate
  7. )
  8. class THVideoIE(InfoExtractor):
  9. _VALID_URL = r'http://(?:www\.)?thvideo\.tv/(?:v/th|mobile\.php\?cid=)(?P<id>[0-9]+)'
  10. _TEST = {
  11. 'url': 'http://thvideo.tv/v/th1987/',
  12. 'md5': 'fa107b1f73817e325e9433505a70db50',
  13. 'info_dict': {
  14. 'id': '1987',
  15. 'ext': 'mp4',
  16. 'title': '【动画】秘封活动记录 ~ The Sealed Esoteric History.分镜稿预览',
  17. 'display_id': 'th1987',
  18. 'thumbnail': 'http://thvideo.tv/uploadfile/2014/0722/20140722013459856.jpg',
  19. 'description': '社团京都幻想剧团的第一个东方二次同人动画作品「秘封活动记录 ~ The Sealed Esoteric History.」 本视频是该动画第一期的分镜草稿...',
  20. 'upload_date': '20140722'
  21. }
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. # extract download link from mobile player page
  27. webpage_player = self._download_webpage(
  28. 'http://thvideo.tv/mobile.php?cid=%s-0' % (video_id),
  29. video_id, note='Downloading video source page')
  30. video_url = self._html_search_regex(
  31. r'<source src="(.*?)" type', webpage_player, 'video url')
  32. # extract video info from main page
  33. webpage = self._download_webpage(
  34. 'http://thvideo.tv/v/th%s' % (video_id), video_id)
  35. title = self._og_search_title(webpage)
  36. display_id = 'th%s' % video_id
  37. thumbnail = self._og_search_thumbnail(webpage)
  38. description = self._og_search_description(webpage)
  39. upload_date = unified_strdate(self._html_search_regex(
  40. r'span itemprop="datePublished" content="(.*?)">', webpage,
  41. 'upload date', fatal=False))
  42. return {
  43. 'id': video_id,
  44. 'ext': 'mp4',
  45. 'url': video_url,
  46. 'title': title,
  47. 'display_id': display_id,
  48. 'thumbnail': thumbnail,
  49. 'description': description,
  50. 'upload_date': upload_date
  51. }