mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
10 years ago
|
from __future__ import unicode_literals
|
||
|
|
||
11 years ago
|
import os
|
||
|
import subprocess
|
||
|
|
||
|
from .common import FileDownloader
|
||
|
from ..utils import (
|
||
10 years ago
|
check_executable,
|
||
11 years ago
|
encodeFilename,
|
||
|
)
|
||
|
|
||
|
|
||
10 years ago
|
class RtspFD(FileDownloader):
|
||
11 years ago
|
def real_download(self, filename, info_dict):
|
||
11 years ago
|
url = info_dict['url']
|
||
11 years ago
|
self.report_destination(filename)
|
||
|
tmpfilename = self.temp_name(filename)
|
||
|
|
||
10 years ago
|
if check_executable('mplayer', ['-h']):
|
||
|
args = [
|
||
|
'mplayer', '-really-quiet', '-vo', 'null', '-vc', 'dummy',
|
||
|
'-dumpstream', '-dumpfile', tmpfilename, url]
|
||
|
elif check_executable('mpv', ['-h']):
|
||
|
args = [
|
||
|
'mpv', '-really-quiet', '--vo=null', '--stream-dump=' + tmpfilename, url]
|
||
|
else:
|
||
10 years ago
|
self.report_error('MMS or RTSP download detected but neither "mplayer" nor "mpv" could be run. Please install any.')
|
||
11 years ago
|
return False
|
||
|
|
||
9 years ago
|
self._debug_cmd(args)
|
||
|
|
||
11 years ago
|
retval = subprocess.call(args)
|
||
|
if retval == 0:
|
||
|
fsize = os.path.getsize(encodeFilename(tmpfilename))
|
||
10 years ago
|
self.to_screen('\r[%s] %s bytes' % (args[0], fsize))
|
||
11 years ago
|
self.try_rename(tmpfilename, filename)
|
||
|
self._hook_progress({
|
||
|
'downloaded_bytes': fsize,
|
||
|
'total_bytes': fsize,
|
||
|
'filename': filename,
|
||
|
'status': 'finished',
|
||
|
})
|
||
|
return True
|
||
|
else:
|
||
10 years ago
|
self.to_stderr('\n')
|
||
10 years ago
|
self.report_error('%s exited with code %d' % (args[0], retval))
|
||
11 years ago
|
return False
|