[英]LG TV UPnP/DLNA error illegal mime-type
我正在嘗試編寫一個在我的 LG 智能電視上播放視頻文件的 python 腳本。 到目前為止,我已經設置了可以流式傳輸音頻和視頻的minidlna服務器。 它適用於同一局域網上的其他設備。 然后我有以下代碼可以在我的電視上播放一些東西:
#import requests
#import sys
def upload_file(location, filename, controlURL):
headers = {
'Content-Type': 'text/xml; charset=utf-8',
'SOAPAction': '"urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"',
}
#<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/"><item id="0" parentID="-1" restricted="0"><dc:title>Video</dc:title><dc:creator>Anonymous</dc:creator><upnp:class>object.item.videoItem</upnp:class><res protocolInfo="http-get:*:video/mp4:*" sec:URIType="public">"http://' + location + '/' + filename + '"</res></item></DIDL-Lite>
data = '<?xml version "1.0" encoding="utf-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CurrentURI><![CDATA[http://' + location + '/' + filename + ']]></CurrentURI><CurrentURIMetaData></CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>'
print "[*] Sending request"
try:
response = requests.post(controlURL, headers=headers, data=data, timeout=2)
except Exception as ex:
print "[x] Request failed!"
sys.exit(ex)
print response.status_code
print response.text
upload_file("192.168.22.217:8200", "MediaItems/22.mp4", "http://192.168.22.198:1498/AVTransport/8167b8fc-bf78-da40-9070-5663d70a8a40/control.xml")
無論是否有請求中的元數據,它都不起作用。 我可以訪問192.168.22.217:8200/MediaItems/22.mp4
並且它可以正常播放視頻並且 controlURL 是一個有效的(我實際上得到的有點不同,但這超出了這個問題的范圍)。
電視成功聯系了 minidlna 服務器(我可以從以 HTTP 200 響應並開始提供文件的日志中看到它),但電視不播放任何內容並以 HTTP 500 響應:
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring>UPnPError</faultstring>
<detail>
<UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
<errorCode>714</errorCode>
<errorDescription>Illegal MIME-type</errorDescription>
</UPnPError>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
為什么會發生? video/mp4
是有效的 MIME 類型。 我還嘗試了其他幾種 MIME 類型和文件格式,每次都得到相同的結果。
電視:LG 43UJ635V
筆記本電腦:MacBook Pro
minidlnad 版本: minidlnad -V -> Version 1.1.5
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.