User-agent spoofing in xbmc.player().play()

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Closed
scorpion303 Offline
Junior Member
Posts: 1
Joined: Aug 2004
Reputation: 0
Post: #1
when i stream a file through xbmc using the xbmc.player().play("[url]http://38.39.23.24/stream/stream.asx"[/url]) method.. it always sends 'xbmc-mplayer/1.1.0(mpeg)' as the user-agent to the webserver, and the get-requests looks like this in the webserver-logs:
Quote:38.39.23.23 - user1 [30/aug/2005:22:39:21 +0100] "get /streams/stream.asx http/1.0" 200 143088 "-" "[b]xbmc-mplayer/1.1.0(mpeg)[/b]"

is there any possibility to spoof this user-agent, so the webserver sees an windows media player request?

this seems to be possible for normal url-gets (like in the following examle). does anyone know if this works for streams too?

Quote:urldata = none
urlheaders = {

'user-agent': 'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; .net clr 1.1.4322)',

'accept-language': 'en-us',

}
urllib.urlopen(url,urldata, urlheaders)
find
pike Offline
Project Manager
Posts: 4,849
Joined: Sep 2003
Reputation: 29
Location: Sweden
Post: #2
that user-agent is sent to "trick" shoutcast servers into letting us connect without issues.

it's defined in mplayer.conf

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: badge.gif]
find
m3ga Offline
Junior Member
Posts: 1
Joined: Sep 2005
Reputation: 0
Post: #3
(pike @ aug. 31 2005,15:18 Wrote:that user-agent is sent to "trick" shoutcast servers into letting us connect without issues.

it's defined in mplayer.conf
he wants to look the dutch big brother streams. the server looks at the user agent. if its not windows media player the stream will be of much lower quality. so he needs to spoof the user agent.
find
xbmc007 Offline
Junior Member
Posts: 14
Joined: Apr 2013
Reputation: 0
Post: #4
Was the functionality ever added? Any way to pass user agent to xbmc.player().play()?
find
sphere Offline
Team-Kodi Member
Posts: 1,227
Joined: Jul 2009
Reputation: 50
Location: Germany
Post: #5
It is already possible to send the user-agent, my Apple iTunes Trailers Add-on does so. Have a look to the code.

Just add
Code:
|User-Agent=Foo%20Bar
to the play URL.
So
Code:
http://www.server.com/path/to/file?param=value&param2=value2
becomes
Code:
http://www.server.com/path/to/file?param=value&param2=value2|User-Agent=Whatever%20you%20like

Btw, this works for all Headers (e.g. Cookie).

My GitHub. My Add-ons:
[Image: IOoywq0.jpg]
find
xbmc007 Offline
Junior Member
Posts: 14
Joined: Apr 2013
Reputation: 0
Post: #6
Thanks!
find
ololoe Offline
Banned
Posts: 71
Joined: Jul 2013
Post: #7
(2013-07-15 14:35)sphere Wrote:  Just add
Code:
|User-Agent=Foo%20Bar
to the play URL.
So
Code:
http://www.server.com/path/to/file?param=value&param2=value2
becomes
Code:
http://www.server.com/path/to/file?param=value&param2=value2|User-Agent=Whatever%20you%20like

Btw, this works for all Headers (e.g. Cookie).
This looks awful. Typical WORKAROUND. Is | allowed in urls?
find
HenryFord Offline
Posting Freak
Posts: 1,272
Joined: Jan 2010
Reputation: 19
Post: #8
Of course it is*

* = Of course meaning that you're dealing with an unsafe character here and they need to be/should be encoded...
However - is the pipe actually part of the URL? Way I understood it, it is a direct header modifier and not actually part of the URL.

Need help? Check out my XBMC Frodo Guide. It contains full featured guides to Sickbeard and CouchPotato as well.

[Image: all-fanart.jpg]
(This post was last modified: 2013-07-29 00:52 by HenryFord.)
find
ololoe Offline
Banned
Posts: 71
Joined: Jul 2013
Post: #9
A WORKAROUND is to append shit to url that doesn't belong there rather then supporting them via keyword arguments.
find
amet Offline
Retired Team-Kodi Member
Posts: 4,087
Joined: Jul 2009
Reputation: 41
Location: Novi Sad / Dubai
Post: #10
I suggest you modify your attitude as everyone on this thread is trying to help YOU, if you don't like the way things are done you are welcome to fix it and suggest we pull it into mainline using PR system on github.
(This post was last modified: 2013-07-29 07:18 by amet.)
find
ololoe Offline
Banned
Posts: 71
Joined: Jul 2013
Post: #11
(2013-07-29 07:16)amet Wrote:  as everyone on this thread is trying to help YOU
No.
find
HenryFord Offline
Posting Freak
Posts: 1,272
Joined: Jan 2010
Reputation: 19
Post: #12
Best thing to wake up to today:
ololoe
Banned

Need help? Check out my XBMC Frodo Guide. It contains full featured guides to Sickbeard and CouchPotato as well.

[Image: all-fanart.jpg]
find
amet Offline
Retired Team-Kodi Member
Posts: 4,087
Joined: Jul 2009
Reputation: 41
Location: Novi Sad / Dubai
Post: #13
Heh, I wonder who did it
find
Martijn Offline
Team Kodi
Posts: 11,906
Joined: Jul 2011
Reputation: 170
Location: Dawn of time
Post: #14
me
he has a month to cool down. see other thread where he wasn't nice
http://forum.xbmc.org/showthread.php?tid...pid1472592

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

For your mediacenter artwork go to
[Image: fanarttv.png]
(This post was last modified: 2013-07-29 08:30 by Martijn.)
find
amet Offline
Retired Team-Kodi Member
Posts: 4,087
Joined: Jul 2009
Reputation: 41
Location: Novi Sad / Dubai
Post: #15
Yeah, didn't see that before... *sigh , I wonder why people get like that...
find