Skip to content
This repository
Browse code

release 2011.12.18

  • Loading branch information...
commit d6639d05c205953cd5f3d45e26946477b2cdc735 1 parent 633cf7c
Philipp Hagemeister authored December 17, 2011
2  LATEST_VERSION
... ...
@@ -1 +1 @@
1  
-2011.12.15
  1
+2011.12.18
4  README.md
Source Rendered
@@ -83,8 +83,8 @@ which means you can modify it, redistribute it or use it however you like.
83 83
 ### Post-processing Options:
84 84
     --extract-audio          convert video files to audio-only files (requires
85 85
                              ffmpeg and ffprobe)
86  
-    --audio-format FORMAT    "best", "aac", "vorbis", "mp3", or "m4a"; best by
87  
-                             default
  86
+    --audio-format FORMAT    "best", "aac", "vorbis", "mp3", "m4a", or "wav";
  87
+                             best by default
88 88
     --audio-quality QUALITY  ffmpeg audio bitrate specification, 128k by default
89 89
     -k, --keep-video         keeps the video file on disk after the post-
90 90
                              processing; the video is erased by default
72  youtube-dl
@@ -18,7 +18,7 @@ __author__  = (
18 18
 	)
19 19
 
20 20
 __license__ = 'Public Domain'
21  
-__version__ = '2011.12.15'
  21
+__version__ = '2011.12.18'
22 22
 
23 23
 UPDATE_URL = 'https://raw.github.com/rg3/youtube-dl/master/youtube-dl'
24 24
 
@@ -759,10 +759,6 @@ class FileDownloader(object):
759 759
 		if filename is None:
760 760
 			return
761 761
 
762  
-		if self.params.get('nooverwrites', False) and os.path.exists(filename):
763  
-			self.to_stderr(u'WARNING: file exists and will be skipped')
764  
-			return
765  
-
766 762
 		try:
767 763
 			dn = os.path.dirname(filename)
768 764
 			if dn != '' and not os.path.exists(dn):
@@ -804,16 +800,19 @@ class FileDownloader(object):
804 800
 				return
805 801
 
806 802
 		if not self.params.get('skip_download', False):
807  
-			try:
808  
-				success = self._do_download(filename, info_dict)
809  
-			except (OSError, IOError), err:
810  
-				raise UnavailableVideoError
811  
-			except (urllib2.URLError, httplib.HTTPException, socket.error), err:
812  
-				self.trouble(u'ERROR: unable to download video data: %s' % str(err))
813  
-				return
814  
-			except (ContentTooShortError, ), err:
815  
-				self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded))
816  
-				return
  803
+			if self.params.get('nooverwrites', False) and os.path.exists(filename):
  804
+				success = True
  805
+			else:
  806
+				try:
  807
+					success = self._do_download(filename, info_dict)
  808
+				except (OSError, IOError), err:
  809
+					raise UnavailableVideoError
  810
+				except (urllib2.URLError, httplib.HTTPException, socket.error), err:
  811
+					self.trouble(u'ERROR: unable to download video data: %s' % str(err))
  812
+					return
  813
+				except (ContentTooShortError, ), err:
  814
+					self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded))
  815
+					return
817 816
 	
818 817
 			if success:
819 818
 				try:
@@ -3925,6 +3924,9 @@ class PostProcessor(object):
3925 3924
 		"""
3926 3925
 		return information # by default, do nothing
3927 3926
 
  3927
+class AudioConversionError(BaseException):
  3928
+	def __init__(self, message):
  3929
+		self.message = message
3928 3930
 
3929 3931
 class FFmpegExtractAudioPP(PostProcessor):
3930 3932
 
@@ -3956,12 +3958,23 @@ class FFmpegExtractAudioPP(PostProcessor):
3956 3958
 
3957 3959
 	@staticmethod
3958 3960
 	def run_ffmpeg(path, out_path, codec, more_opts):
  3961
+		if codec is None:
  3962
+			acodec_opts = []
  3963
+		else:
  3964
+			acodec_opts = ['-acodec', codec]
  3965
+		cmd = ['ffmpeg', '-y', '-i', path, '-vn'] + acodec_opts + more_opts + ['--', out_path]
3959 3966
 		try:
3960  
-			cmd = ['ffmpeg', '-y', '-i', path, '-vn', '-acodec', codec] + more_opts + ['--', out_path]
3961  
-			ret = subprocess.call(cmd, stdout=file(os.path.devnull, 'w'), stderr=subprocess.STDOUT)
3962  
-			return (ret == 0)
  3967
+			p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  3968
+			stdout,stderr = p.communicate()
3963 3969
 		except (IOError, OSError):
3964  
-			return False
  3970
+			e = sys.exc_info()[1]
  3971
+			if isinstance(e, OSError) and e.errno == 2:
  3972
+				raise AudioConversionError('ffmpeg not found. Please install ffmpeg.')
  3973
+			else:
  3974
+				raise e
  3975
+		if p.returncode != 0:
  3976
+			msg = stderr.strip().split('\n')[-1]
  3977
+			raise AudioConversionError(msg)
3965 3978
 
3966 3979
 	def run(self, information):
3967 3980
 		path = information['filepath']
@@ -3995,7 +4008,7 @@ class FFmpegExtractAudioPP(PostProcessor):
3995 4008
 					more_opts += ['-ab', self._preferredquality]
3996 4009
 		else:
3997 4010
 			# We convert the audio (lossy)
3998  
-			acodec = {'mp3': 'libmp3lame', 'aac': 'aac', 'm4a': 'aac', 'vorbis': 'libvorbis'}[self._preferredcodec]
  4011
+			acodec = {'mp3': 'libmp3lame', 'aac': 'aac', 'm4a': 'aac', 'vorbis': 'libvorbis', 'wav': None}[self._preferredcodec]
3999 4012
 			extension = self._preferredcodec
4000 4013
 			more_opts = []
4001 4014
 			if self._preferredquality is not None:
@@ -4006,14 +4019,21 @@ class FFmpegExtractAudioPP(PostProcessor):
4006 4019
 				more_opts += ['-absf', 'aac_adtstoasc']
4007 4020
 			if self._preferredcodec == 'vorbis':
4008 4021
 				extension = 'ogg'
  4022
+			if self._preferredcodec == 'wav':
  4023
+				extension = 'wav'
  4024
+				more_opts += ['-f', 'wav']
4009 4025
 
4010 4026
 		(prefix, ext) = os.path.splitext(path)
4011 4027
 		new_path = prefix + '.' + extension
4012 4028
 		self._downloader.to_screen(u'[ffmpeg] Destination: %s' % new_path)
4013  
-		status = self.run_ffmpeg(path, new_path, acodec, more_opts)
4014  
-
4015  
-		if not status:
4016  
-			self._downloader.to_stderr(u'WARNING: error running ffmpeg')
  4029
+		try:
  4030
+			self.run_ffmpeg(path, new_path, acodec, more_opts)
  4031
+		except:
  4032
+			etype,e,tb = sys.exc_info()
  4033
+			if isinstance(e, AudioConversionError):
  4034
+				self._downloader.to_stderr(u'ERROR: audio conversion failed: ' + e.message)
  4035
+			else:
  4036
+				self._downloader.to_stderr(u'ERROR: error running ffmpeg')
4017 4037
 			return None
4018 4038
 
4019 4039
  		# Try to update the date time for extracted audio file.
@@ -4252,7 +4272,7 @@ def parseOpts():
4252 4272
 	postproc.add_option('--extract-audio', action='store_true', dest='extractaudio', default=False,
4253 4273
 			help='convert video files to audio-only files (requires ffmpeg and ffprobe)')
4254 4274
 	postproc.add_option('--audio-format', metavar='FORMAT', dest='audioformat', default='best',
4255  
-			help='"best", "aac", "vorbis", "mp3", or "m4a"; best by default')
  4275
+			help='"best", "aac", "vorbis", "mp3", "m4a", or "wav"; best by default')
4256 4276
 	postproc.add_option('--audio-quality', metavar='QUALITY', dest='audioquality', default='128K',
4257 4277
 			help='ffmpeg audio bitrate specification, 128k by default')
4258 4278
 	postproc.add_option('-k', '--keep-video', action='store_true', dest='keepvideo', default=False,
@@ -4398,7 +4418,7 @@ def _real_main():
4398 4418
 	except (TypeError, ValueError), err:
4399 4419
 		parser.error(u'invalid playlist end number specified')
4400 4420
 	if opts.extractaudio:
4401  
-		if opts.audioformat not in ['best', 'aac', 'mp3', 'vorbis', 'm4a']:
  4421
+		if opts.audioformat not in ['best', 'aac', 'mp3', 'vorbis', 'm4a', 'wav']:
4402 4422
 			parser.error(u'invalid audio format specified')
4403 4423
 
4404 4424
 	# File downloader
2  youtube_dl/__init__.py
@@ -18,7 +18,7 @@
18 18
 	)
19 19
 
20 20
 __license__ = 'Public Domain'
21  
-__version__ = '2011.12.15'
  21
+__version__ = '2011.12.18'
22 22
 
23 23
 UPDATE_URL = 'https://raw.github.com/rg3/youtube-dl/master/youtube-dl'
24 24
 

0 notes on commit d6639d0

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