[request]To add in addons-api a possibility to spoof HTTP headers (user-agent,...)
#1
For better work with Internet streams please add in addons-api the posibility to change (spoof) http-headers for internal player of xbmc. I mean the following

- the possibility to change (to spoof) the existing User-Agent - "XBMC/PRE-10.5 r31655 (Linux; openSUSE 11.3 (i586); 2.6.34-12-desktop i686; http://www.xbmc.org)" to another
With it some servers report to xbmc as "HTTP/1.1 403 Bite my shiny metal ass!"

- to handle the cookes
- to handle the Rederer

You can have a look on existing situation when the Internet server refused to the connection with xbmx - HTTP/1.1 403 Bite my shiny metal ass!
Image
Nvidia Shield
kodi 18.1 RC1
Reply
#2
You can, yes. Use a pipe: |User-Agent=foo
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
do you mean something like this (as spiff wrote several months ago)

Code:
http://www.some.where/foo?bar=1|User-Agent=some-app+v1+(Linux%3bandsoon)
Nvidia Shield
kodi 18.1 RC1
Reply
#4
Yes.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
ok - we will try it. But what about of another http headers - referer, accept-encoding, ...
How to spoof the http headers as for true Internet browser ??

Does it possible to implement such features more elegant way as the following variants

Code:
xbmc.Player().add_http_header('User-Agent', 'Opera/9.80 (X11; Linux i686; U; ru) Presto/2.6.30 Version/10.70')
xbmc.Player().add_http_header('Host', new_host)
xbmc.Player().add_http_header('Accept', 'text/html, application/xml, application/xhtml+xml, */*')
xbmc.Player().add_http_header('Accept-Language', 'ru,en;q=0.9')
xbmc.Player().add_http_header('Accept-Charset', 'iso-8859-1, utf-8, utf-16, *;q=0.1')
xbmc.Player().add_http_header('Accept-Encoding', 'deflate, gzip, x-gzip, identity, *;q=0')
xbmc.Player().add_http_header('Referer', 'http://turbofilm.tv/media/swf/Player14.swf')
xbmc.Player().add_http_header('Connection', 'Keep-Alive'
xbmc.Player().play(url, item)

or

Code:
headers = {'User-Agent': 'Opera/9.80 (X11; Linux i686; U; ru) Presto/2.6.30 Version/10.70',\
'Host': 'cdn.turbofilm.tv',\
'Accept': 'text/html, application/xml, application/xhtml+xml, */*',\
'Accept-Language': 'ru,en;q=0.9',\
'Accept-Charset': 'iso-8859-1, utf-8, utf-16, *;q=0.1',\
'Accept-Encoding': 'deflate, gzip, x-gzip, identity, *;q=0',\
'Referer': 'http://turbofilm.tv/media/swf/Player14.swf',\
'Cookie': 'IAS_ID='+str(phpsessid)+'; _',\
'Cookie2': '$Version=1',\
'Connection': 'Keep-Alive' }

xbmc.Player().add_http_headers(headers)
xbmc.Player().play(url, item)

or

Code:
conn = httplib.HTTPConnection('cdn.turbofilm.tv', 80, 10)
headers = {'User-Agent': 'Opera/9.80 (X11; Linux i686; U; ru) Presto/2.6.30 Version/10.70',\
'Host': 'cdn.turbofilm.tv',\
'Accept': 'text/html, application/xml, application/xhtml+xml, */*',\
'Accept-Language': 'ru,en;q=0.9',\
'Accept-Charset': 'iso-8859-1, utf-8, utf-16, *;q=0.1',\
'Accept-Encoding': 'deflate, gzip, x-gzip, identity, *;q=0',\
'Referer': 'http://turbofilm.tv/media/swf/Player14.swf',\
'Cookie': 'IAS_ID='+str(phpsessid)+'; _',\
'Cookie2': '$Version=1',\
'Connection': 'Keep-Alive' }

conn.request("GET", path, '', headers)
xbmc.Player().play(conn.getresponse(), item)


this is really actual issue for Internet streams and xbmc
Nvidia Shield
kodi 18.1 RC1
Reply
#6
jmarshall Wrote:You can, yes. Use a pipe: |User-Agent=foo

we tried like this, but without success

xbmc has sent such modified header

Code:
09:19:38 T:3041859440 M:1684439040   DEBUG: CPlayerCoreFactory::GetPlayers([url]http://217.199.218.60/67b8b1c4fedb2e38e2eb26f403b9c2b2642b0a2c/4226/1f4ec3d14de0d8a49a757f36492fc79e/0/760d9ba55e29de987c99ee00916c9c467150ef6e/3938238515b33cd43526f20e90d59d32889cb047/5cb613e3be04fa68c9e787b828ba98e2d07e7cb4|Referer=http%3A%2F%2Fturbofilm.tv%2Fmedia%2Fswf%2FPlayer14.swf|User-Agent=Opera%2F9.80+%28X11%3B+Linux+i686%3B+U%3B+ru%29+Presto%2F2.6.30+Version%2F10.70[/url]

what's wrong ?

Image
Nvidia Shield
kodi 18.1 RC1
Reply
#7
Looks like you've set referer using |Referer="foo" and then tacked another pipe on with the User-Agent. The pipe indicates the beginning of protocol options. Each protocol option is separated with an &.

http://some.url/foo?bar=1|Referer=ass&User-Agent=bender

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#8
not quite correct. the stuff after | needs to be url-encoded.
Reply
#9
Ok. Since HTTP headers and everything is fine.
Now you have to disable the request HEAD. We must immediately make a GET / ...
How?
Image
Reply
#10
why need for xbmc HEAD methos at all ?
seems to me it's absolutely useless for xbmc

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

Quote:9.4 HEAD

The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.

The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be used to update a previously cached entity from that resource. If the new field values indicate that the cached entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or Last-Modified), then the cache MUST treat the cache entry as stale.
Nvidia Shield
kodi 18.1 RC1
Reply
#11
need to create the ticket for fixing such thing ?
Nvidia Shield
kodi 18.1 RC1
Reply
#12
How to add User-Agent when playing music streams (http, mms, etc...)?
I tried this:
Code:
item.setInfo(type='music',infoLabels={'title':name,'artist': '101.RU'})
uri = sys.argv[0] + '?mode=Watch'
uri += '&name=' + urllib.quote_plus(name)
uri += '&url=' + urllib.quote_plus(wma_purl+'|Referer=http://101.ru/101player/uppod7.swf')
xbmcplugin.addDirectoryItem(handle, uri, item)
***
def Watch(url, name):
    xbmc.output('Watch(%s, %s)'%(url, name))
    xbmc.Player().play(url)
Code:
xbmc.log
17:50:07 T:2872048496 M:1842667520  NOTICE: Watch(mms://eu1.101.ru/c4_1_128?st=|Referer=http://101.ru/101player/uppod7.swf, КлассикаЖанра)
17:50:07 T:3025221488 M:1842032640  NOTICE: DVDPlayer: Opening: mms://eu1.101.ru/c4_1_128?st=|Referer=http://101.ru/101player/uppod7.swf
17:50:07 T:3025221488 M:1842032640 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
17:50:07 T:2824690544 M:1842032640  NOTICE: Creating InputStream

Headers:
Code:
GET /c4_4_128?st=[b]|Referer=http://101.ru/101player/uppod7.swf[/b] HTTP/1.0
Accept: */*
User-Agent: NSPlayer/4.1.0.3856
Host: eu1.101.ru:80
Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=1,max-duration=0
Pragma: xClientGUID={c77e7400-738a-11d2-9add-0020af0a3278}
Connection: Close
Referer should become one of the Headers, but he hit the GET
How do I fix?
PS: When playing video okay
Reply
#13
seppius Wrote:How to add User-Agent when playing music streams (http, mms, etc...)?
I tried this:
Code:
item.setInfo(type='music',infoLabels={'title':name,'artist': '101.RU'})
uri = sys.argv[0] + '?mode=Watch'
uri += '&name=' + urllib.quote_plus(name)
uri += '&url=' + urllib.quote_plus(wma_purl+'|Referer=http://101.ru/101player/uppod7.swf')
xbmcplugin.addDirectoryItem(handle, uri, item)
***
def Watch(url, name):
    xbmc.output('Watch(%s, %s)'%(url, name))
    xbmc.Player().play(url)
Code:
xbmc.log
17:50:07 T:2872048496 M:1842667520  NOTICE: Watch(mms://eu1.101.ru/c4_1_128?st=|Referer=http://101.ru/101player/uppod7.swf, КлассикаЖанра)
17:50:07 T:3025221488 M:1842032640  NOTICE: DVDPlayer: Opening: mms://eu1.101.ru/c4_1_128?st=|Referer=http://101.ru/101player/uppod7.swf
17:50:07 T:3025221488 M:1842032640 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
17:50:07 T:2824690544 M:1842032640  NOTICE: Creating InputStream

Headers:
Code:
GET /c4_4_128?st=[b]|Referer=http://101.ru/101player/uppod7.swf[/b] HTTP/1.0
Accept: */*
User-Agent: NSPlayer/4.1.0.3856
Host: eu1.101.ru:80
Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=1,max-duration=0
Pragma: xClientGUID={c77e7400-738a-11d2-9add-0020af0a3278}
Connection: Close
Referer should become one of the Headers, but he hit the GET
How do I fix?
PS: When playing video okay


Yup I'm getting the same exact problem, anyone else seeing this or know how to fix it ?
Reply
#14
I have not found a solution. It looks like the developers do not care about us.
Reply
#15
or may be they are busy with future Dharma release Smile
Nvidia Shield
kodi 18.1 RC1
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
[request]To add in addons-api a possibility to spoof HTTP headers (user-agent,...)00