diff --git a/README.md b/README.md index 281a14fa9..64a64c610 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ which means you can modify it, redistribute it or use it however you like. %(autonumber)s to get an automatically incremented number, %(ext)s for the filename extension, %(upload_date)s for the upload date (YYYYMMDD), - %(extractor)s for the extractor used (youtube, metacafe, + %(extractor)s for the provider (youtube, metacafe, etc), %(id)s for the video id and %% for a literal percent. Use - to output to stdout. -a, --batch-file FILE file containing URLs to download ('-' for stdin) diff --git a/youtube-dl.1 b/youtube-dl.1 index a9cd368e8..a3100e9e4 100644 --- a/youtube-dl.1 +++ b/youtube-dl.1 @@ -55,7 +55,7 @@ redistribute it or use it however you like. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ %(autonumber)s\ to\ get\ an\ automatically\ incremented \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ number,\ %(ext)s\ for\ the\ filename\ extension, \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ %(upload_date)s\ for\ the\ upload\ date\ (YYYYMMDD), -\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ %(extractor)s\ for\ the\ extractor\ used\ (youtube,\ metacafe, +\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ %(extractor)s\ for\ the\ provider\ (youtube,\ metacafe, \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ etc),\ %(id)s\ for\ the\ video\ id\ and\ %%\ for\ a\ literal \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ percent.\ Use\ -\ to\ output\ to\ stdout. -a,\ --batch-file\ FILE\ \ \ \ file\ containing\ URLs\ to\ download\ (\[aq]-\[aq]\ for\ stdin) diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index 8d428b25d..9e5ea7c61 100644 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -683,11 +683,16 @@ class DailymotionIE(InfoExtractor): return video_uploader = mobj.group(1) + video_upload_date = u'NA' + mobj = re.search(r'
([0-9]{2})-([0-9]{2})-([0-9]{4})
', webpage) + if mobj is not None: + video_upload_date = mobj.group(3) + mobj.group(2) + mobj.group(1) + return [{ 'id': video_id.decode('utf-8'), 'url': video_url.decode('utf-8'), 'uploader': video_uploader.decode('utf-8'), - 'upload_date': u'NA', + 'upload_date': video_upload_date, 'title': video_title, 'ext': video_extension.decode('utf-8'), 'format': u'NA', diff --git a/youtube_dl/PostProcessor.py b/youtube_dl/PostProcessor.py index 375da1aa3..c57b9b609 100644 --- a/youtube_dl/PostProcessor.py +++ b/youtube_dl/PostProcessor.py @@ -89,15 +89,25 @@ class FFmpegExtractAudioPP(PostProcessor): return None except (IOError, OSError): return None - audio_codec = None + codec = None + duration = None for line in output.split('\n'): if line.startswith('codec_name='): - audio_codec = line.split('=')[1].strip() - elif line.strip() == 'codec_type=audio' and audio_codec is not None: - return audio_codec - return None + codec = line.split('=')[1].strip() + elif line.startswith('duration='): + duration = line.split('=')[1].strip() + try: + duration = float(duration) + except: + duration = None + elif line.strip() == '[/STREAM]' and codec is not None: + break + return { + 'codec': codec, + 'duration': duration + } - def run_ffmpeg(self, path, out_path, codec, more_opts): + def run_ffmpeg(self, path, out_path, codec, more_opts, duration): if not self._exes['ffmpeg'] and not self._exes['avconv']: raise AudioConversionError('ffmpeg or avconv not found. Please install one.') if codec is None: @@ -107,16 +117,55 @@ class FFmpegExtractAudioPP(PostProcessor): cmd = ([self._exes['avconv'] or self._exes['ffmpeg'], '-y', '-i', encodeFilename(path), '-vn'] + acodec_opts + more_opts + ['--', encodeFilename(out_path)]) - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout,stderr = p.communicate() + start = time.time() + # open process redirecting stderr to stdout + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) + import fcntl + import errno + import select + # entire captured output + p_output = '' + # size= 765kB time=243.67 bitrate= 25.7kbits/s + reo = re.compile("""size=\s*(?P\S+) # size + \stime=(?P