]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/downloader/rtsp.py
debian/changelog: Annotate bugs to close.
[youtubedl] / youtube_dl / downloader / rtsp.py
1 from __future__ import unicode_literals
2
3 import os
4 import subprocess
5
6 from .common import FileDownloader
7 from ..utils import (
8 check_executable,
9 encodeFilename,
10 )
11
12
13 class RtspFD(FileDownloader):
14 def real_download(self, filename, info_dict):
15 url = info_dict['url']
16 self.report_destination(filename)
17 tmpfilename = self.temp_name(filename)
18
19 if check_executable('mplayer', ['-h']):
20 args = [
21 'mplayer', '-really-quiet', '-vo', 'null', '-vc', 'dummy',
22 '-dumpstream', '-dumpfile', tmpfilename, url]
23 elif check_executable('mpv', ['-h']):
24 args = [
25 'mpv', '-really-quiet', '--vo=null', '--stream-dump=' + tmpfilename, url]
26 else:
27 self.report_error('MMS or RTSP download detected but neither "mplayer" nor "mpv" could be run. Please install any.')
28 return False
29
30 retval = subprocess.call(args)
31 if retval == 0:
32 fsize = os.path.getsize(encodeFilename(tmpfilename))
33 self.to_screen('\r[%s] %s bytes' % (args[0], fsize))
34 self.try_rename(tmpfilename, filename)
35 self._hook_progress({
36 'downloaded_bytes': fsize,
37 'total_bytes': fsize,
38 'filename': filename,
39 'status': 'finished',
40 })
41 return True
42 else:
43 self.to_stderr('\n')
44 self.report_error('%s exited with code %d' % (args[0], retval))
45 return False