Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid passing untrusted strings to the shell #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion engines/ct.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def download(self, quality, movie):
app = parsedurl.path[1:] + '?' + parsedurl.query

# rtmpdump --live kvůli restartům - viz http://www.abclinuxu.cz/blog/pb/2011/5/televize-9-ctstream-3#18
return ('rtmp', filename, { 'url': base, 'playpath': src, 'app' : app, 'rtmpdump_args' : '--live'} )
return ('rtmp', filename, { 'url': base, 'playpath': src, 'app' : app, 'rtmpdump_args' : ['--live']} )

def download_srt(self):
if self.subtitles is None:
Expand Down
2 changes: 1 addition & 1 deletion engines/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def download(self, quality, movie):
return ('rtmp', 'output.flv', {'url' : 'rtmp://server.net:port/appname/playpath',
'playpath' : 'opravdu/divnej/playpath',
'app' : 'opravdu/divná/aplikace',
'rtmpdump_args' : '--live',
'rtmpdump_args' : ['--live'],
'token' : 'bezpečnostní_kód'} )

return ('http', 'output.flv', {'url' : 'http://televize.tv/archiv/porad.flv' } )
Expand Down
2 changes: 1 addition & 1 deletion engines/kraus.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def download(self, quality, movie):

filename = self.movielist[movie][2] if quality == 'low' else self.movielist[movie][1]

return ('rtmp', filename, {'url' : rtmp+'/'+filename, 'rtmpdump_args' : '--live'} )
return ('rtmp', filename, {'url' : rtmp+'/'+filename, 'rtmpdump_args' : ['--live']} )
2 changes: 1 addition & 1 deletion engines/nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ def download(self, quality, movie):

return ("rtmp", filename , { 'url' : baseUrl,
'playpath' : playpath,
'rtmpdump_args' : '--live'})
'rtmpdump_args' : ['--live']})

2 changes: 1 addition & 1 deletion engines/prima.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def download_rtmp(self, quality):
baseUrl = baseUrl.replace("token", "token_"+str(zoneGEO))

return ("rtmp", playpath[:-3]+'flv' , { 'url' : baseUrl+'/'+playpath,
'rtmpdump_args' : '--live'})
'rtmpdump_args' : ['--live']})

def download_cdn(self):
cdnId = re.findall(r"cdnID=(\d+)", self.page)[0]
Expand Down
21 changes: 10 additions & 11 deletions tv-dl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

import argparse,os,sys,re,logging
import argparse,os,sys,re,logging,subprocess

class TVDownloader:
def __init__(self, args):
Expand Down Expand Up @@ -70,35 +70,34 @@ class TVDownloader:

@classmethod
def download(cls, d, outfile):
cmd = ''
cmd = []
if d[0] == 'rtmp':
args = ''
parms = d[2]
cmd = ['rtmpdump', '-r', parms['url'], '-o', outfile]
if 'playpath' in parms:
args += ' -y "{}"'.format(parms['playpath'])
cmd.extend(['-y', parms['playpath']])

if 'app' in parms:
args += ' -a "{}"'.format(parms['app'])
cmd.extend(['-a', parms['app']])

if 'token' in parms:
args += ' -T "{}"'.format(parms['token'])
cmd.extend(['-T', parms['token']])

if 'rtmpdump_args' in parms:
args += ' '+parms['rtmpdump_args']
cmd.extend(parms['rtmpdump_args'])

cmd = 'rtmpdump -r "{}" -o "{}" {}'.format(parms['url'], outfile, args)

elif d[0] == 'http':
cmd = 'wget -O "{}" "{}"'.format(d[1], d[2]['url'] )
cmd = ['wget', '-O', d[1], d[2]['url']]

elif d[0] == "text":
open(outfile, 'wb').write(d[2])

else:
raise ValueError("Nepodporovaný protokol: {}".format(d[0]) )

log.info('Příkaz: {}'.format(cmd))
os.system(cmd)
log.info('Příkaz: ' + ' '.join(cmd))
subprocess.call(cmd)


if __name__ == "__main__":
Expand Down