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.

68 lines
2.5 KiB

  1. # encoding: utf-8
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. compat_urllib_parse,
  6. determine_ext,
  7. )
  8. class DaumIE(InfoExtractor):
  9. _VALID_URL = r'https?://tvpot\.daum\.net/.*?clipid=(?P<id>\d+)'
  10. IE_NAME = u'daum.net'
  11. _TEST = {
  12. u'url': u'http://tvpot.daum.net/clip/ClipView.do?clipid=52554690',
  13. u'file': u'52554690.mp4',
  14. u'info_dict': {
  15. u'title': u'DOTA 2GETHER 시즌2 6회 - 2부',
  16. u'description': u'DOTA 2GETHER 시즌2 6회 - 2부',
  17. u'upload_date': u'20130831',
  18. u'duration': 3868,
  19. },
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. video_id = mobj.group(1)
  24. canonical_url = 'http://tvpot.daum.net/v/%s' % video_id
  25. webpage = self._download_webpage(canonical_url, video_id)
  26. full_id = self._search_regex(
  27. r'<iframe src="http://videofarm.daum.net/controller/video/viewer/Video.html\?.*?vid=(.+?)[&"]',
  28. webpage, u'full id')
  29. query = compat_urllib_parse.urlencode({'vid': full_id})
  30. info = self._download_xml(
  31. 'http://tvpot.daum.net/clip/ClipInfoXml.do?' + query, video_id,
  32. u'Downloading video info')
  33. urls = self._download_xml(
  34. 'http://videofarm.daum.net/controller/api/open/v1_2/MovieData.apixml?' + query,
  35. video_id, u'Downloading video formats info')
  36. self.to_screen(u'%s: Getting video urls' % video_id)
  37. formats = []
  38. for format_el in urls.findall('result/output_list/output_list'):
  39. profile = format_el.attrib['profile']
  40. format_query = compat_urllib_parse.urlencode({
  41. 'vid': full_id,
  42. 'profile': profile,
  43. })
  44. url_doc = self._download_xml(
  45. 'http://videofarm.daum.net/controller/api/open/v1_2/MovieLocation.apixml?' + format_query,
  46. video_id, note=False)
  47. format_url = url_doc.find('result/url').text
  48. formats.append({
  49. 'url': format_url,
  50. 'ext': determine_ext(format_url),
  51. 'format_id': profile,
  52. })
  53. return {
  54. 'id': video_id,
  55. 'title': info.find('TITLE').text,
  56. 'formats': formats,
  57. 'thumbnail': self._og_search_thumbnail(webpage),
  58. 'description': info.find('CONTENTS').text,
  59. 'duration': int(info.find('DURATION').text),
  60. 'upload_date': info.find('REGDTTM').text[:8],
  61. }