Skip to content

Commit

Permalink
Add mediaplayer as a new browser.type
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalman committed Jun 11, 2024
1 parent b52a7ea commit de4978e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/enums/ua-parser-enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const BrowserType = Object.freeze({
EMAIL: 'email',
FETCHER: 'fetcher',
INAPP: 'inapp',
MEDIAPLAYER: 'mediaplayer',
MODULE: 'module'
});

Expand Down
3 changes: 3 additions & 0 deletions src/enums/ua-parser-enums.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const BrowserType = Object.freeze({
EMAIL: 'email',
FETCHER: 'fetcher',
INAPP: 'inapp',
MEDIAPLAYER: 'mediaplayer',
MODULE: 'module'
});

Expand Down Expand Up @@ -228,6 +229,7 @@ const Vendor = Object.freeze({
PALM: 'Palm',
PANASONIC: 'Panasonic',
PEBBLE: 'Pebble',
PICO: 'Pico',
POLYTRON: 'Polytron',
REALME: 'Realme',
RIM: 'RIM',
Expand Down Expand Up @@ -325,6 +327,7 @@ const OS = Object.freeze({
PALM: 'Palm',
PC_BSD: 'PC-BSD',
PCLINUXOS: 'PCLinuxOS',
PICO: 'Pico',
PLAN9: 'Plan9',
PLAYSTATION: 'PlayStation',
QNX: 'QNX',
Expand Down
51 changes: 26 additions & 25 deletions src/extensions/ua-parser-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const CLI = 'cli';
const EMAIL = 'email';
const FETCHER = 'fetcher';
const INAPP = 'inapp';
const MEDIAPLAYER = 'mediaplayer';
const MODULE = 'module';

//////////////////////
Expand Down Expand Up @@ -221,104 +222,104 @@ const MediaPlayers = Object.freeze({

/(apple(?:coremedia|))\/([\w\._]+)/i, // Generic Apple CoreMedia
/(coremedia) v([\w\._]+)/i
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(aqualung|lyssna|bsplayer)\/([\w\.-]+)/i // Aqualung/Lyssna/BSPlayer
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(ares|ossproxy)\s([\w\.-]+)/i // Ares/OSSProxy
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(audacious|audimusicstream|amarok|bass|core|dalvik|gnomemplayer|music on console|nsplayer|psp-internetradioplayer|videos)\/([\w\.-]+)/i,
// Audacious/AudiMusicStream/Amarok/BASS/OpenCORE/Dalvik/GnomeMplayer/MoC
// NSPlayer/PSP-InternetRadioPlayer/Videos
/(clementine|music player daemon)\s([\w\.-]+)/i, // Clementine/MPD
/(lg player|nexplayer)\s([\d\.]+)/i,
/player\/(nexplayer|lg player)\s([\w\.-]+)/i // NexPlayer/LG Player
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [
/(nexplayer)\s([\w\.-]+)/i // Nexplayer
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(flrp)\/([\w\.-]+)/i // Flip Player
], [[NAME, 'Flip Player'], VERSION], [
], [[NAME, 'Flip Player'], VERSION, [TYPE, MEDIAPLAYER]], [

/(fstream|nativehost|queryseekspider|ia-archiver|facebookexternalhit)/i
// FStream/NativeHost/QuerySeekSpider/IA Archiver/facebookexternalhit
], [NAME], [
], [NAME, [TYPE, MEDIAPLAYER]], [

/(gstreamer) souphttpsrc.+libsoup\/([\w\.-]+)/i
// Gstreamer
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(htc streaming player)\s[\w_]+\s\/\s([\d\.]+)/i, // HTC Streaming Player
/(java|python-urllib|python-requests|wget|libcurl)\/([\w\.-_]+)/i,
// Java/urllib/requests/wget/cURL
/(lavf)([\d\.]+)/i // Lavf (FFMPEG)
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(htc_one_s)\/([\d\.]+)/i, // HTC One S
], [[NAME, /_/g, ' '], VERSION], [
], [[NAME, /_/g, ' '], VERSION, [TYPE, MEDIAPLAYER]], [

/(mplayer)(?:\s|\/)(?:(?:sherpya-){0,1}svn)(?:-|\s)(r\d+(?:-\d+[\w\.-]+))/i,
// MPlayer SVN
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(mplayer)(?:\s|\/)([\w\.-]+)/i, // MPlayer
/(mplayer) unknown-([\w\.\-]+)/i // MPlayer UNKNOWN
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(mplayer)/i, // MPlayer (no other info)
/(yourmuze)/i, // YourMuze
/(media player classic|nero showtime)/i // Media Player Classic/Nero ShowTime
], [NAME], [
], [NAME, [TYPE, MEDIAPLAYER]], [

/(nero (?:home|scout))\/([\w\.-]+)/i // Nero Home/Nero Scout
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(nokia\d+)\/([\w\.-]+)/i // Nokia
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/\s(songbird)\/([\w\.-]+)/i // Songbird/Philips-Songbird
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(winamp)3 version ([\w\.-]+)/i, // Winamp
/(winamp)\s([\w\.-]+)/i,
/(winamp)mpeg\/([\w\.-]+)/i
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(ocms-bot|tapinradio|tunein radio|unknown|winamp|inlight radio)/i // OCMS-bot/tap in radio/tunein/unknown/winamp (no other info)
// inlight radio
], [NAME], [
], [NAME, [TYPE, MEDIAPLAYER]], [

/(quicktime|rma|radioapp|radioclientapplication|soundtap|totem|stagefright|streamium)\/([\w\.-]+)/i
// QuickTime/RealMedia/RadioApp/RadioClientApplication/
// SoundTap/Totem/Stagefright/Streamium
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(smp)([\d\.]+)/i // SMP
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(vlc) media player - version ([\w\.]+)/i, // VLC Videolan
/(vlc)\/([\w\.-]+)/i,
/(xbmc|gvfs|xine|xmms|irapp)\/([\w\.-]+)/i, // XBMC/gvfs/Xine/XMMS/irapp
/(foobar2000)\/([\d\.]+)/i, // Foobar2000
/(itunes)\/([\d\.]+)/i // iTunes
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(wmplayer)\/([\w\.-]+)/i, // Windows Media Player
/(windows-media-player)\/([\w\.-]+)/i
], [[NAME, /-/g, ' '], VERSION], [
], [[NAME, /-/g, ' '], VERSION, [TYPE, MEDIAPLAYER]], [

/windows\/([\w\.-]+) upnp\/[\d\.]+ dlnadoc\/[\d\.]+ (home media server)/i,
// Windows Media Server
], [VERSION, [NAME, 'Windows']], [
], [VERSION, [NAME, 'Windows'], [TYPE, MEDIAPLAYER]], [

/(com\.riseupradioalarm)\/([\d\.]*)/i // RiseUP Radio Alarm
], [NAME, VERSION], [
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [

/(rad.io)\s([\d\.]+)/i, // Rad.io
/(radio.(?:de|at|fr))\s([\d\.]+)/i
], [[NAME, 'rad.io'], VERSION]
], [[NAME, 'rad.io'], VERSION, [TYPE, MEDIAPLAYER]]
]
});

Expand Down
2 changes: 1 addition & 1 deletion src/main/ua-parser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare namespace UAParser {
name?: string;
version?: string;
major?: string;
type?: 'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'module';
type?: 'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'mediaplayer' | 'module';
}

interface ICPU extends IData<ICPU> {
Expand Down
2 changes: 1 addition & 1 deletion test/dts-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ expectType<IBrowser>(browser);
expectType<string | undefined>(browser.name);
expectType<string | undefined>(browser.version);
expectType<string | undefined>(browser.major);
expectType<'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'module' | undefined>(browser.type);
expectType<'crawler' | 'cli' | 'email' | 'fetcher' | 'inapp' | 'mediaplayer' | 'module' | undefined>(browser.type);
expectType<boolean>(browser.is(''));
expectType<string>(browser.toString());
expectType<IBrowser | PromiseLike<IBrowser>>(browser.withClientHints());
Expand Down

0 comments on commit de4978e

Please sign in to comment.