Check-in [e8c162f72a]
Overview
| Comment: | Add UserAgentSwitcher plugin. (Just for experimenting really, not required.)
|
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
e8c162f72ad3624b5d322003b00a85e3 |
| User & Date: | mario on 2015-04-06 18:53:27 |
| Original Comment: | Add UserAgentSwitcher plugin. (Just for experimenting really, not required.) |
| Other Links: | manifest | tags |
Context
|
2015-04-06
| ||
| 18:55 | Add workaround for ArgumentParser, which tries to map config: descriptors onto AP.add_argument(*yikes) params. check-in: 24a5fe69a1 user: mario tags: trunk | |
| 18:53 |
Add UserAgentSwitcher plugin. (Just for experimenting really, not required.)
| |
|
2015-04-05
| ||
| 22:06 | Fix manual Makefile `install` rules. Update -D debug notes in README. Release as 2.1.5 (beta). check-in: b6b64a45f6 user: mario tags: trunk, 2.1.5 | |
Changes
Makefile became executable with contents [0d018ef979].
| ︙ | ︙ |
Added channels/useragentswitcher.py version [08fd23fe89].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# encoding: UTF-8
# api: streamtuner2
# title: User Agent Switcher
# description: Mask streamtuner2 as browser or different radio player.
# version: 0.1
# type: feature
# category: session
# priority: rare
# config:
# { type=select, name=useragent, value=Streamtuner2, select="Streamtuner2|VLC|Firefox|Chrome|Android|MSIE|iTunes", description=Which browser string to use for HTTP requests. }
# hooks: config_save
#
# This is currently unneeded.
from config import *
from channels import *
import ahttp
# override ahttp.session headers, hooks into config dialog
class useragentswitcher():
module = "useragentswitcher"
meta = plugin_meta()
map = {
"default": "streamtuner2/2.1 (X11; Linux amd64; rv:33.0) like WinAmp/2.1",
"vlc": "vlc 1.1.0-git-20100330-0003",
"firefox": "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
"chrome": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
"android": "Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
"msie": "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko",
"itunes": "iTunes/9.0.3 (Macintosh; U; Intel Mac OS X 10_6_2; en-ca)",
"googlebot": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
}
# register
def __init__(self, parent):
conf.add_plugin_defaults(self.meta, self.module)
parent.hooks["config_save"].append(self.apply)
self.apply()
# set new browser string in requests session
def apply(self):
ua = self.map.get(conf.useragent.lower(), self.map["default"])
if ua:
__print__(dbg.HTTP, "UserAgentSwitcher:", ua)
ahttp.session.headers.update({ "User-Agent": ua })
|