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.

75 lines
2.7 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 ..compat import (
  6. compat_urllib_parse,
  7. )
  8. class DaumIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:m\.)?tvpot\.daum\.net/(?:v/|.*?clipid=)(?P<id>[^?#&]+)'
  10. IE_NAME = 'daum.net'
  11. _TESTS = [{
  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. 'url': 'http://tvpot.daum.net/v/vab4dyeDBysyBssyukBUjBz',
  23. 'only_matching': True,
  24. }, {
  25. 'url': 'http://tvpot.daum.net/v/07dXWRka62Y%24',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. mobj = re.match(self._VALID_URL, url)
  30. video_id = mobj.group('id')
  31. canonical_url = 'http://tvpot.daum.net/v/%s' % video_id
  32. webpage = self._download_webpage(canonical_url, video_id)
  33. full_id = self._search_regex(
  34. r'src=["\']http://videofarm\.daum\.net/controller/video/viewer/Video\.html\?.*?vid=(.+?)[&"\']',
  35. webpage, 'full id')
  36. query = compat_urllib_parse.urlencode({'vid': full_id})
  37. info = self._download_xml(
  38. 'http://tvpot.daum.net/clip/ClipInfoXml.do?' + query, video_id,
  39. 'Downloading video info')
  40. urls = self._download_xml(
  41. 'http://videofarm.daum.net/controller/api/open/v1_2/MovieData.apixml?' + query,
  42. video_id, 'Downloading video formats info')
  43. formats = []
  44. for format_el in urls.findall('result/output_list/output_list'):
  45. profile = format_el.attrib['profile']
  46. format_query = compat_urllib_parse.urlencode({
  47. 'vid': full_id,
  48. 'profile': profile,
  49. })
  50. url_doc = self._download_xml(
  51. 'http://videofarm.daum.net/controller/api/open/v1_2/MovieLocation.apixml?' + format_query,
  52. video_id, note='Downloading video data for %s format' % profile)
  53. format_url = url_doc.find('result/url').text
  54. formats.append({
  55. 'url': format_url,
  56. 'format_id': profile,
  57. })
  58. return {
  59. 'id': video_id,
  60. 'title': info.find('TITLE').text,
  61. 'formats': formats,
  62. 'thumbnail': self._og_search_thumbnail(webpage),
  63. 'description': info.find('CONTENTS').text,
  64. 'duration': int(info.find('DURATION').text),
  65. 'upload_date': info.find('REGDTTM').text[:8],
  66. }