Skip to content
This repository
Browse code

transplant gist of 7151f63

  • Loading branch information...
commit a67bdc34fa3e524a7168ab477d28aaf54a051956 1 parent b3a653c
Philipp Hagemeister phihag authored

Showing 2 changed files with 20 additions and 19 deletions. Show diff stats Hide diff stats

  1. +14 16 youtube-dl
  2. +6 3 youtube_dl/__init__.py
30 youtube-dl
@@ -766,7 +766,7 @@ class FileDownloader(object):
766 766 raise MaxDownloadsReached()
767 767
768 768 filename = self.prepare_filename(info_dict)
769   -
  769 +
770 770 # Forced printings
771 771 if self.params.get('forcetitle', False):
772 772 print info_dict['title'].encode(preferredencoding(), 'xmlcharrefreplace')
@@ -842,7 +842,7 @@ class FileDownloader(object):
842 842 except (ContentTooShortError, ), err:
843 843 self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded))
844 844 return
845   -
  845 +
846 846 if success:
847 847 try:
848 848 self.post_process(filename, info_dict)
@@ -1183,7 +1183,7 @@ class YoutubeIE(InfoExtractor):
1183 1183 '43': '360x640',
1184 1184 '44': '480x854',
1185 1185 '45': '720x1280',
1186   - }
  1186 + }
1187 1187 IE_NAME = u'youtube'
1188 1188
1189 1189 def report_lang(self):
@@ -2559,8 +2559,7 @@ class YoutubePlaylistIE(InfoExtractor):
2559 2559
2560 2560 # Extract video identifiers
2561 2561 ids_in_page = []
2562   - video_indicator = self._VIDEO_INDICATOR_TEMPLATE % playlist_id
2563   - for mobj in re.finditer(video_indicator, page):
  2562 + for mobj in re.finditer(self._VIDEO_INDICATOR_TEMPLATE % playlist_id, page):
2564 2563 if mobj.group(1) not in ids_in_page:
2565 2564 ids_in_page.append(mobj.group(1))
2566 2565 video_ids.extend(ids_in_page)
@@ -2571,7 +2570,6 @@ class YoutubePlaylistIE(InfoExtractor):
2571 2570
2572 2571 playliststart = self._downloader.params.get('playliststart', 1) - 1
2573 2572 playlistend = self._downloader.params.get('playlistend', -1)
2574   -
2575 2573 if playlistend == -1:
2576 2574 video_ids = video_ids[playliststart:]
2577 2575 else:
@@ -3021,14 +3019,14 @@ class BlipTVIE(InfoExtractor):
3021 3019 data = json_data['Post']
3022 3020 else:
3023 3021 data = json_data
3024   -
  3022 +
3025 3023 upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
3026 3024 video_url = data['media']['url']
3027 3025 umobj = re.match(self._URL_EXT, video_url)
3028 3026 if umobj is None:
3029 3027 raise ValueError('Can not determine filename extension')
3030 3028 ext = umobj.group(1)
3031   -
  3029 +
3032 3030 info = {
3033 3031 'id': data['item_id'],
3034 3032 'url': video_url,
@@ -3062,7 +3060,7 @@ class MyVideoIE(InfoExtractor):
3062 3060
3063 3061 def __init__(self, downloader=None):
3064 3062 InfoExtractor.__init__(self, downloader)
3065   -
  3063 +
3066 3064 def report_download_webpage(self, video_id):
3067 3065 """Report webpage download."""
3068 3066 self._downloader.to_screen(u'[myvideo] %s: Downloading webpage' % video_id)
@@ -3129,7 +3127,7 @@ class ComedyCentralIE(InfoExtractor):
3129 3127
3130 3128 def report_extraction(self, episode_id):
3131 3129 self._downloader.to_screen(u'[comedycentral] %s: Extracting information' % episode_id)
3132   -
  3130 +
3133 3131 def report_config_download(self, episode_id):
3134 3132 self._downloader.to_screen(u'[comedycentral] %s: Downloading configuration' % episode_id)
3135 3133
@@ -3556,7 +3554,7 @@ class SoundcloudIE(InfoExtractor):
3556 3554 mobj = re.search('track-description-value"><p>(.*?)</p>', webpage)
3557 3555 if mobj:
3558 3556 description = mobj.group(1)
3559   -
  3557 +
3560 3558 # upload date
3561 3559 upload_date = None
3562 3560 mobj = re.search("pretty-date'>on ([\w]+ [\d]+, [\d]+ \d+:\d+)</abbr></h2>", webpage)
@@ -3691,7 +3689,7 @@ class MixcloudIE(InfoExtractor):
3691 3689 url_list = jsonData[fmt][bitrate]
3692 3690 except TypeError: # we have no bitrate info.
3693 3691 url_list = jsonData[fmt]
3694   -
  3692 +
3695 3693 return url_list
3696 3694
3697 3695 def check_urls(self, url_list):
@@ -3811,7 +3809,7 @@ class StanfordOpenClassroomIE(InfoExtractor):
3811 3809 info = {
3812 3810 'id': _simplify_title(course + '_' + video),
3813 3811 }
3814   -
  3812 +
3815 3813 self.report_extraction(info['id'])
3816 3814 baseUrl = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/'
3817 3815 xmlUrl = baseUrl + video + '.xml'
@@ -3945,7 +3943,7 @@ class MTVIE(InfoExtractor):
3945 3943 self._downloader.trouble(u'ERROR: unable to extract performer')
3946 3944 return
3947 3945 performer = _unescapeHTML(mobj.group(1).decode('iso-8859-1'))
3948   - video_title = performer + ' - ' + song_name
  3946 + video_title = performer + ' - ' + song_name
3949 3947
3950 3948 mobj = re.search(r'<meta name="mtvn_uri" content="([^"]+)"/>', webpage)
3951 3949 if mobj is None:
@@ -4187,7 +4185,7 @@ def updateSelf(downloader, filename):
4187 4185 try:
4188 4186 urlh = urllib.urlopen(UPDATE_URL)
4189 4187 newcontent = urlh.read()
4190   -
  4188 +
4191 4189 vmatch = re.search("__version__ = '([^']+)'", newcontent)
4192 4190 if vmatch is not None and vmatch.group(1) == __version__:
4193 4191 downloader.to_screen(u'youtube-dl is up-to-date (' + __version__ + ')')
@@ -4608,7 +4606,7 @@ def _real_main():
4608 4606 parser.error(u'you must provide at least one URL')
4609 4607 else:
4610 4608 sys.exit()
4611   -
  4609 +
4612 4610 try:
4613 4611 retcode = fd.download(all_urls)
4614 4612 except MaxDownloadsReached:
9 youtube_dl/__init__.py
@@ -2507,7 +2507,7 @@ class YoutubePlaylistIE(InfoExtractor):
2507 2507
2508 2508 _VALID_URL = r'(?:https?://)?(?:\w+\.)?youtube\.com/(?:(?:course|view_play_list|my_playlists|artist|playlist)\?.*?(p|a|list)=|user/.*?/user/|p/|user/.*?#[pg]/c/)(?:PL)?([0-9A-Za-z-_]+)(?:/.*?/([0-9A-Za-z_-]+))?.*'
2509 2509 _TEMPLATE_URL = 'http://www.youtube.com/%s?%s=%s&page=%s&gl=US&hl=en'
2510   - _VIDEO_INDICATOR = r'/watch\?v=(.+?)&'
  2510 + _VIDEO_INDICATOR_TEMPLATE = r'/watch\?v=(.+?)&amp;list=PL%s&'
2511 2511 _MORE_PAGES_INDICATOR = r'(?m)>\s*Next\s*</a>'
2512 2512 _youtube_ie = None
2513 2513 IE_NAME = u'youtube:playlist'
@@ -2559,7 +2559,7 @@ def _real_extract(self, url):
2559 2559
2560 2560 # Extract video identifiers
2561 2561 ids_in_page = []
2562   - for mobj in re.finditer(self._VIDEO_INDICATOR, page):
  2562 + for mobj in re.finditer(self._VIDEO_INDICATOR_TEMPLATE % playlist_id, page):
2563 2563 if mobj.group(1) not in ids_in_page:
2564 2564 ids_in_page.append(mobj.group(1))
2565 2565 video_ids.extend(ids_in_page)
@@ -2570,7 +2570,10 @@ def _real_extract(self, url):
2570 2570
2571 2571 playliststart = self._downloader.params.get('playliststart', 1) - 1
2572 2572 playlistend = self._downloader.params.get('playlistend', -1)
2573   - video_ids = video_ids[playliststart:playlistend]
  2573 + if playlistend == -1:
  2574 + video_ids = video_ids[playliststart:]
  2575 + else:
  2576 + video_ids = video_ids[playliststart:playlistend]
2574 2577
2575 2578 for id in video_ids:
2576 2579 self._youtube_ie.extract('http://www.youtube.com/watch?v=%s' % id)

0 comments on commit a67bdc3

Please sign in to comment.
Something went wrong with that request. Please try again.