我的python代码应该下载rmtp视频,但出现此错误:
错误:无法连接“ str”和“ function”对象
我以前从未见过此错误,请帮忙!
cmd = 'rtmpdump -r -T "sdjsds8" -r "'+player+'" -a "vod" -f "WIN 13,0,0,182" -W "http://website.fr/components/com_vodvideo/mediaplayer/player-licensed.swf" -p "http://website.fr" -y "mp4:'+code+'" -o "MaVideo.flv'
这是我的代码:
import ConfigParser
import requests,re,os,sys
from xrez import quality_FHD
from xrez import quality_HD
from xrez import quality_SD
def Fonction_smil():
global Resolution
config = ConfigParser.ConfigParser()
config.read('config.ini')
quality = config.get('SETTINGS', 'video_quality')
if quality == '1080p':
Resolution = (quality_FHD('qualityFHD'))
elif quality == '720p':
Resolution = (quality_HD('qualityHD'))
elif quality == '480p':
Resolution = (quality_SD('qualitySD'))
url = Resolution
print "downloading with requests"
r = requests.get(url)
with open("video.smil", "wb") as code:
code.write(r.content)
mykey = open("/home/gaaara/adn/video.smil", "r")
for text in mykey:
match = re.search('base="(.*?)"', text)
if match:
vod_links = str(match.group(1))
print vod_links
print 'telechargement de la video...'
cmd = 'rtmpdump -v -T "fbfhfhfh" -r "'+ url +'" -a "vod" -f "WIN 13,0,0,182" -W "http://website.com/components/com_vodvideo/mediaplayer/player-licensed.swf" -p "http://website.com" -y "mp4:'+code+'" -o "mavideo.mp4"'
os.system(cmd)
编辑:
我在主体脚本上有此错误,但在smil.py上却没有。
当我导入功能
from smil import Fonction_smil
我得到这个错误
追溯(最近一次通话):文件“ start.py”,第35行,在
从smil导入Fonction_smil文件“ files / smil.py”,行
30,如果匹配:NameError:未定义名称“匹配”
最佳答案
您的url
变量不包含字符串,而是一个函数。您可能需要执行类似"..." + url() + "..."
的操作。
您的code
变量包含一个文件,而不是字符串。因此,您不能使用字符串+
。这将是下一个问题:)