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.

70 lines
2.5 KiB

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