prx-podagent
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -9,6 +9,7 @@ exports.agents = [ | ||
[/^AndroidDownloadManager/, null, 36, 42], | ||
[/^AntennaPod/, 5, 36, 42], | ||
[/^AntennaPod|^de\.danoeh\.antennapod/, 5, 36, 42], | ||
[/^Apache-HttpClient/, null, 36, 42], | ||
[/^APKXDL.+Android/, null, 36, 42], | ||
[/^IOSAudiobooks.+CFNetwork/, 101, 36, 43], | ||
[/^BashPodder/, 119, 35, 49], | ||
[/^Mozilla\/5\.0.+BeyondPod/, 33, 36, 42], | ||
@@ -63,3 +64,3 @@ [/^Bose\//, 86, 37, null], | ||
[/^KERA.+IOS/, 106, 36, 43], | ||
[/^Kids( |%20)Listen.+CFNetwork/, 107, 36, 43], | ||
[/^Kids Listen.+CFNetwork/, 107, 36, 43], | ||
[/^Kodi.+Windows/, 108, 37, 41], | ||
@@ -78,5 +79,5 @@ [/^Kodi.+Android/, 108, 37, 42], | ||
[/^myTuner.+CFNetwork/, 87, 36, 43], | ||
[/^mytuner.+Android/, 87, 36, 42], | ||
[/^(mytuner.+Android)|^MyTuner-ExoPlayer/, 87, 36, 42], | ||
[/^MusicBee/, 109, 35, 41], | ||
[/^NPR%20One.+CFNetwork/, 13, 36, 43], | ||
[/^NPR One.+CFNetwork/, 13, 36, 43], | ||
[/^NPROneAndroid/, 13, 36, 42], | ||
@@ -88,2 +89,3 @@ [/^(NSPlayer|WMFSDK|WMPlayer)/, 55, 35, 41], | ||
[/^Outcast/, 111, 68, 69], | ||
[/^Mozilla.+MSOffice 16/, 120, null, null], | ||
[/^Overcast/, 14, 36, 43], | ||
@@ -97,3 +99,3 @@ [/^Pandora.+Android/, 82, 36, 42], | ||
[/^Playapod.+Android/, 112, 36, 42], | ||
[/^Player( |%20)FM.+CFNetwork/, 15, 36, 43], | ||
[/^Player FM.+CFNetwork/, 15, 36, 43], | ||
[/^Player FM/, 15, 36, 42], | ||
@@ -110,5 +112,7 @@ [/^Plex.+iOS/, 113, 36, 43], | ||
[/^(PodcastAddict|Podcast Addict).+Android/, 18, 36, 42], | ||
[/^podcast\/.+(CFNetwork|iOS)/, 19, 36, 43], | ||
[/^(com\.evolve\.)?podcast\/.+(CFNetwork|iOS)/, 19, 36, 43], | ||
[/^PodcastRepublic.+Android/, 58, 36, 42], | ||
[/^Podcoin/, 98, 36, null], | ||
[/^Podimo.+Android/, 118, 36, 42], | ||
[/^Podimo.+iOS/, 118, 36, 43], | ||
[/^Podkicker/, 20, 36, 42], | ||
@@ -138,2 +142,4 @@ [/^PRI\/.+CFNetwork/, 114, 36, 43], | ||
[/^TED.+Android/, 59, 36, 42], | ||
[/^This Am Life.+Android/, 117, 36, 42], | ||
[/^ThisAmericanLife.+CFNetwork/, 117, 36, 43], | ||
[/^TREBLE/, 84, 36, 43], | ||
@@ -152,3 +158,4 @@ [/^TuneIn.+CFNetwork/, 60, 36, 43], | ||
[/^Zune/, 24, 36, 41], | ||
[/^Podcasts/, 25, 36, 43], | ||
[/^(Podcasts|Podcast’ler|Podcast|Podcaster|Podcasti|Podcastit|Podcastok|Podcasturi|Podcasty|Podkaster|Balados|Подкасти|Подкасты|פודקאסטים|البودكاست|पॉडकास्ट|พ็อดคาสท์|播客|팟캐스트)\/.+(x86_64)/, 25, 35, 45], | ||
[/^(Podcasts|Podcast’ler|Podcast|Podcaster|Podcasti|Podcastit|Podcastok|Podcasturi|Podcasty|Podkaster|Balados|Подкасти|Подкасты|פודקאסטים|البودكاست|पॉडकास्ट|พ็อดคาสท์|播客|팟캐스트)\//, 25, 36, 43], | ||
[/^itunesstored/, 25, 36, 43], | ||
@@ -193,9 +200,11 @@ [/^AppleCoreMedia.+Apple TV/, 25, 38, 43], | ||
[/^Mozilla\/5\.0.+Linux.+Firefox/, 28, 39, 49], | ||
[/^Mozilla\/5\.0.+Linux.+Chrome/, 29, 39, 49], | ||
[/^Mozilla\/5\.0.+(OpenBSD|NetBSD|Linux).+Chrome/, 29, 39, 49], | ||
[/^Mozilla\/5\.0.+Linux/, null, 39, 49], | ||
[/^Opera\/.+Linux/, 116, 39, 49], | ||
[/^Mozilla\/5\.0.+Gecko.+Firefox/, 28, 39, null], | ||
[/^Chrome/, 29, 39, null], | ||
[/^Mozilla\/5\.0( compatible)?$/, null, 39, null], | ||
[/bot|spider|crawl|slurp|scan|scrap|archiver|transcoder|^curl|wget|^ruby|^python|^java|perl|php|httpclient|http-client|wordpress|facebook|yahoo|^pinterest|HWCDN|appengine|hwcdn|httrack/i, null, null, null, true], | ||
[/^fyyd-poll|^itms|^mozilla\/5.0.+google-podcast|^stitcherbot|^rest-client|castfeedvalidator|^amazonnewscontentservice|^trackable|luminary\/1\.0|spotify\/1\.0/i, null, null, null, true] | ||
[/^Linux;Android [0-9]/, null, null, 42], | ||
[/^fyyd-poll|^itms|^mozilla\/5.0.+google-podcast|^stitcherbot|^rest-client|castfeedvalidator|^amazonnewscontentservice|^trackable|luminary\/1\.0|spotify\/1\.0|^podtrac network/i, null, null, null, true], | ||
[/bot|spider|crawl|slurp|scan|scrap|archiver|transcoder|^curl|wget|^ruby|^python|^java|perl|php|httpclient|http-client|wordpress|facebook|yahoo|^pinterest|HWCDN|appengine|hwcdn|httrack|feedstation/i, null, null, null, true] | ||
]; | ||
@@ -318,3 +327,7 @@ exports.tags = { | ||
115: 'WBUR App', | ||
116: 'Opera' | ||
116: 'Opera', | ||
117: 'This American Life', | ||
118: 'Podimo', | ||
119: 'BashPodder', | ||
120: 'Outlook' | ||
}; |
@@ -14,3 +14,3 @@ const db = require('./db/agents.lock.js'); | ||
for (let i = 0; i < db.agents.length; i++) { | ||
if (db.agents[i][0].test(agentStr)) { | ||
if (db.agents[i][0].test(decodeURIComponent(agentStr))) { | ||
data = exports.format(db.agents[i], i); | ||
@@ -32,3 +32,3 @@ break; | ||
for (let i = 0; i < db.agents.length; i++) { | ||
if (db.agents[i][0].test(agentStr)) { | ||
if (db.agents[i][0].test(decodeURIComponent(agentStr))) { | ||
datas.push(exports.format(db.agents[i], i)); | ||
@@ -35,0 +35,0 @@ } |
{ | ||
"name": "prx-podagent", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "User-agent parser for common podcast clients", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,3 +44,3 @@ # PRX Podcast User-Agent Parser | ||
var str = 'some-agent-string'; | ||
var str = decodeURIComponent('some-agent-string'); | ||
var agent = db.agents.find(function(a) { return a.regex.test(str); }); | ||
@@ -62,2 +62,3 @@ if (agent) { | ||
def match_agent(str) | ||
str = URI.unescape(str) | ||
DB['agents'].find { |a| Regexp.new(a['regex'], a['ignorecase'] ? 'i' : nil).match(str) }&.tap do |match| | ||
@@ -84,2 +85,3 @@ %w(name type os).each { |k| match[k] = DB['tags'][match[k]] } | ||
$str = urldecode($str) | ||
$match = NULL; | ||
@@ -103,2 +105,13 @@ foreach ($DB['agents'] as $agent) { | ||
### URI Encodings | ||
Note: it's fairly common to see URI encodings in user agent strings. And often | ||
depends on your particular server setup. The regexps in this library are | ||
intended to be used on the fully-uri-decoded `User-Agent` string. So you should | ||
always `decodeURIComponent()` the value before attempting to match. | ||
I've also seen a mix of encoded/decoded spaces within a single user agent | ||
string. Where the first space has been encoded to `%20`, but subsequent ones | ||
are not. So URI decoding is probably a good idea anyways. | ||
## Development | ||
@@ -105,0 +118,0 @@ |
381
145
19741
7