diff --git a/test/test_youtube_lists.py b/test/test_youtube_lists.py index 9c2e82ea3..f4705bc5b 100644 --- a/test/test_youtube_lists.py +++ b/test/test_youtube_lists.py @@ -41,12 +41,6 @@ def test_youtube_playlist(self): ytie_results = [YoutubeIE()._extract_id(r[0]) for r in dl.result] self.assertEqual(ytie_results, [ 'bV9L5Ht9LgY', 'FXxLjLQi3Fg', 'tU3Bgo5qJZE']) - def test_issue_661(self): - dl = FakeDownloader() - ie = YoutubePlaylistIE(dl) - ie.extract('PLMCmkNmxw6Z9eduM7BZjSEh7HiU543Ig0') - self.assertTrue(len(dl.result) > 20) - def test_issue_673(self): dl = FakeDownloader() ie = YoutubePlaylistIE(dl) diff --git a/test/tests.json b/test/tests.json index fd7eb2d65..7af3c2892 100644 --- a/test/tests.json +++ b/test/tests.json @@ -128,18 +128,6 @@ "file": "0732f586d7.mp4", "md5": "f647e9e90064b53b6e046e75d0241fbd" }, - { - "name": "TweetReel", - "url": "http://tweetreel.com/?77smq", - "file": "77smq.mov", - "md5": "56b4d9ca9de467920f3f99a6d91255d6", - "info_dict": { - "uploader": "itszero", - "uploader_id": "itszero", - "upload_date": "20091225", - "description": "Installing Gentoo Linux on Powerbook G4, it turns out the sleep indicator becomes HDD activity indicator :D" - } - }, { "name": "Steam", "url": "http://store.steampowered.com/video/105600/", diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index f668b362b..9b630c123 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -104,7 +104,7 @@ def __init__(self, params): self.params = params if '%(stitle)s' in self.params['outtmpl']: - self.to_stderr(u'WARNING: %(stitle)s is deprecated. Use the %(title)s and the --restrict-filenames flag(which also secures %(uploader)s et al) instead.') + self.report_warning(u'%(stitle)s is deprecated. Use the %(title)s and the --restrict-filenames flag(which also secures %(uploader)s et al) instead.') @staticmethod def format_bytes(bytes): @@ -234,6 +234,18 @@ def trouble(self, message=None, tb=None): raise DownloadError(message) self._download_retcode = 1 + def report_warning(self, message): + ''' + Print the message to stderr, it will be prefixed with 'WARNING:' + If stderr is a tty file the 'WARNING:' will be colored + ''' + if sys.stderr.isatty(): + _msg_header=u'\033[0;33mWARNING:\033[0m' + else: + _msg_header=u'WARNING:' + warning_message=u'%s %s' % (_msg_header,message) + self.to_stderr(warning_message) + def slow_down(self, start_time, byte_counter): """Sleep if the download speed is over the rate limit.""" rate_limit = self.params.get('ratelimit', None) @@ -566,7 +578,7 @@ def post_process(self, filename, ie_info): self.to_screen(u'Deleting original file %s (pass -k to keep)' % filename) os.remove(encodeFilename(filename)) except (IOError, OSError): - self.to_stderr(u'WARNING: Unable to remove downloaded video file') + self.report_warning(u'Unable to remove downloaded video file') def _download_with_rtmpdump(self, filename, url, player_url, page_url): self.report_destination(filename) @@ -574,7 +586,7 @@ def _download_with_rtmpdump(self, filename, url, player_url, page_url): # Check for rtmpdump first try: - subprocess.call(['rtmpdump', '-h'], stdout=(file(os.path.devnull, 'w')), stderr=subprocess.STDOUT) + subprocess.call(['rtmpdump', '-h'], stdout=(open(os.path.devnull, 'w')), stderr=subprocess.STDOUT) except (OSError, IOError): self.trouble(u'ERROR: RTMP download detected but "rtmpdump" could not be run') return False diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index a94648dcf..7ce84fe79 100755 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -308,7 +308,7 @@ def _real_initialize(self): else: raise netrc.NetrcParseError('No authenticators for %s' % self._NETRC_MACHINE) except (IOError, netrc.NetrcParseError) as err: - self._downloader.to_stderr(u'WARNING: parsing .netrc: %s' % compat_str(err)) + self._downloader.report_warning(u'parsing .netrc: %s' % compat_str(err)) return # Set language @@ -317,7 +317,7 @@ def _real_initialize(self): self.report_lang() compat_urllib_request.urlopen(request).read() except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: - self._downloader.to_stderr(u'WARNING: unable to set language: %s' % compat_str(err)) + self._downloader.report_warning(u'unable to set language: %s' % compat_str(err)) return # No authentication to be performed @@ -328,7 +328,7 @@ def _real_initialize(self): try: login_page = compat_urllib_request.urlopen(request).read().decode('utf-8') except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: - self._downloader.to_stderr(u'WARNING: unable to fetch login page: %s' % compat_str(err)) + self._downloader.report_warning(u'unable to fetch login page: %s' % compat_str(err)) return galx = None @@ -372,10 +372,10 @@ def _real_initialize(self): self.report_login() login_results = compat_urllib_request.urlopen(request).read().decode('utf-8') if re.search(r'(?i)