Coder Social home page Coder Social logo

device_detector's Introduction

DeviceDetector

DeviceDetector is a precise and fast user agent parser and device detector written in Python, backed by the largest and most up-to-date user agent database.

DeviceDetector will parse any user agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model. DeviceDetector detects thousands of user agent strings, even from rare and obscure browsers and devices.

The DeviceDetector is optimized for speed of detection, by providing optimized code and in-memory caching.

This project originated as a Python port of the Universal Device Detection library. You can find the original code https://github.com/matomo-org/device-detector.

Disclaimer

This port is not an exact copy of the original code; some Pythonic adaptations were used. However, it uses the original regex yaml files, to benefit from updates and pull request to both the original and the ported versions.

Installation

pip install device_detector

Performance Options

CSafeLoader is used if pyyaml is configured --with-libyaml.

The mrab regex module is preferred if installed.

Usage

from device_detector import DeviceDetector

ua = 'Mozilla/5.0 (Linux; Android 4.3; C5502 Build/10.4.1.B.0.101) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.136 Mobile Safari/537.36'

# Parse UA string and load data to dict of 'os', 'client', 'device' keys
device = DeviceDetector(ua).parse()

# Use helper methods to extract data by attribute

device.is_bot()      # >>> False

device.os_name()     # >>> Android
device.os_version()  # >>> 4.3
device.engine()      # >>> WebKit

device.device_brand_name()  # >>> Sony
device.device_brand()       # >>> SO
device.device_model()       # >>> Xperia ZR
device.device_type()        # >>> smartphone

# For much faster performance, skip Bot and Device Hardware Detection
# and extract get OS / App details only.
from device_detector import SoftwareDetector

ua = 'Mozilla/5.0 (Linux; Android 6.0; 4Good Light A103 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36'
device = SoftwareDetector(ua).parse()

device.client_name()        # >>> Chrome Mobile
device.client_short_name()  # >>> CM
device.client_type()        # >>> browser
device.client_version()     # >>> 58.0.3029.83

device.os_name()     # >>> Android
device.os_version()  # >>> 6.0
device.engine()      # >>> WebKit

device.device_brand_name()  # >>> ''
device.device_brand()       # >>> ''
device.device_model()       # >>> ''
device.device_type()        # >>> ''

# Many mobile browser UA strings contain the app info of the APP that's using the browser 
ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57 EtsyInc/5.22 rv:52200.62.0'
device = DeviceDetector(ua).parse()

device.secondary_client_name()     # >>> EtsyInc
device.secondary_client_type()     # >>> generic
device.secondary_client_version()  # >>> 5.22

Device Detector for other languages

There are already a few ports of this tool to other languages:

What Device Detector is able to detect

The lists below are auto generated and updated from time to time. Some of them might not be complete.

Last update: 2021/12/23

List of detected operating systems:

AIX, Android, AmigaOS, tvOS, Arch Linux, BackTrack, Bada, BeOS, BlackBerry OS, BlackBerry Tablet OS, Brew, Caixa Mágica, CentOS, Chrome OS, CyanogenMod, Debian, Deepin, DragonFly, DVKBuntu, Fedora, Fenix, Firefox OS, Fire OS, Freebox, FreeBSD, FydeOS, Gentoo, GridOS, Google TV, HP-UX, Haiku OS, iPadOS, HarmonyOS, HasCodingOS, IRIX, Inferno, Java ME, KaiOS, Knoppix, Kubuntu, GNU/Linux, Lubuntu, Lumin OS, VectorLinux, Mac, Maemo, Mageia, Mandriva, MeeGo, MocorDroid, Mint, MildWild, MorphOS, NetBSD, MTK / Nucleus, MRE, Nintendo, Nintendo Mobile, OS/2, OSF1, OpenBSD, OpenWrt, Ordissimo, PCLinuxOS, PlayStation Portable, PlayStation, Red Hat, RISC OS, Roku OS, Rosa, Remix OS, REX, RazoDroiD, Sabayon, SUSE, Sailfish OS, SeewoOS, Slackware, Solaris, Syllable, Symbian, Symbian OS, Symbian OS Series 40, Symbian OS Series 60, Symbian^3, ThreadX, Tizen, TmaxOS, Ubuntu, watchOS, WebTV, Whale OS, Windows, Windows CE, Windows IoT, Windows Mobile, Windows Phone, Windows RT, Xbox, Xubuntu, YunOs, iOS, palmOS, webOS

List of detected browsers:

115 Browser, 2345 Browser, 360 Phone Browser, 360 Browser, 7654 Browser, Avant Browser, ABrowse, ANT Fresco, ANTGalio, Aloha Browser, Aloha Browser Lite, Amaya, Amigo, Android Browser, AOL Desktop, AOL Shield, Arora, Arctic Fox, Amiga Voyager, Amiga Aweb, Arvin, Atom, Atomic Web Browser, Avast Secure Browser, AVG Secure Browser, Avira Scout, AwoX, Beaker Browser, Beamrise, BlackBerry Browser, Baidu Browser, Baidu Spark, Basilisk, Beonex, BlackHawk, Bunjalloo, B-Line, Blue Browser, Bonsai, Borealis Navigator, Brave, BriskBard, BrowseX, Browzar, Biyubi, Byffox, Camino, CCleaner, ChanjetCloud, Chedot, Centaury, Coc Coc, CoolBrowser, Colibri, Comodo Dragon, Coast, Charon, CM Browser, Chrome Frame, Headless Chrome, Chrome, Chrome Mobile iOS, Conkeror, Chrome Mobile, CoolNovo, CometBird, COS Browser, Cornowser, Chim Lac, ChromePlus, Chromium, Chromium GOST, Cyberfox, Cheshire, Crusta, Craving Explorer, Crazy Browser, Cunaguaro, Chrome Webview, dbrowser, Peeps dBrowser, Deepnet Explorer, deg-degan, Deledao, Delta Browser, DeskBrowse, Dolphin, Dorado, Dot Browser, Dooble, Dillo, DuckDuckGo Privacy Browser, Ecosia, Edge WebView, Epic, Elinks, Element Browser, Elements Browser, eZ Browser, EUI Browser, GNOME Web, Espial TV Browser, Falkon, Faux Browser, Firefox Mobile iOS, Firebird, Fluid, Fennec, Firefox, Firefox Focus, Firefox Reality, Firefox Rocket, Flock, Flow, Firefox Mobile, Fireweb, Fireweb Navigator, Flash Browser, Flast, FreeU, Galeon, Ghostery Privacy Browser, GinxDroid Browser, Glass Browser, Google Earth, GOG Galaxy, GoBrowser, Harman Browser, HasBrowser, Hawk Turbo Browser, Helio, hola! Browser, HotJava, Huawei Browser Mobile, Huawei Browser, iBrowser, iBrowser Mini, IBrowse, iCab, iCab Mobile, Iridium, Iron Mobile, IceCat, IceDragon, Isivioo, Iceweasel, Internet Explorer, IE Mobile, Iron, Japan Browser, Jasmine, JavaFX, Jig Browser, Jig Browser Plus, Jio Browser, K.Browser, Kindle Browser, K-meleon, Konqueror, Kapiko, Kinza, Kiwi, Kode Browser, Kylo, Kazehakase, Cheetah Browser, Lagatos Browser, LieBaoFast, LG Browser, Light, Links, Lolifox, Lovense Browser, LT Browser, LuaKit, Lulumi, Lunascape, Lunascape Lite, Lynx, Mandarin, mCent, MicroB, NCSA Mosaic, Meizu Browser, Mercury, Mobile Safari, Midori, Mobicip, MIUI Browser, Mobile Silk, Minimo, Mint Browser, Maxthon, Maelstrom, MxNitro, Mypal, Monument Browser, MAUI WAP Browser, Navigateur Web, NFS Browser, Nokia Browser, Nokia OSS Browser, Nokia Ovi Browser, Nox Browser, NetSurf, NetFront, NetFront Life, NetPositive, Netscape, NTENT Browser, Oculus Browser, Opera Mini iOS, Obigo, Odin, OceanHero, Odyssey Web Browser, Off By One, OhHai Browser, ONE Browser, Opera GX, Opera Neon, Opera Devices, Opera Mini, Opera Mobile, Opera, Opera Next, Opera Touch, Orca, Ordissimo, Oregano, Origin In-Game Overlay, Origyn Web Browser, Openwave Mobile Browser, OpenFin, OmniWeb, Otter Browser, Palm Blazer, Pale Moon, Polypane, Oppo Browser, Palm Pre, Puffin, Palm WebPro, Palmscape, Perfect Browser, Phantom Browser, Phoenix, Phoenix Browser, PlayFree Browser, Polaris, Polarity, PolyBrowser, PrivacyWall, PSI Secure Browser, Microsoft Edge, Qazweb, QQ Browser Lite, QQ Browser Mini, QQ Browser, Qutebrowser, Quark, QupZilla, Qwant Mobile, QtWebEngine, Realme Browser, Rekonq, RockMelt, Samsung Browser, Sailfish Browser, Seewo Browser, SEMC-Browser, Sogou Explorer, Safari, Safe Exam Browser, SalamWeb, Secure Browser, SFive, Shiira, SimpleBrowser, Sizzy, Skyfire, Seraphic Sraf, Sleipnir, Slimjet, SP Browser, Stampy Browser, 7Star, Smart Lenovo Browser, Smooz, Snowshoe, Sogou Mobile Browser, Spectre Browser, Splash, Sputnik Browser, Sunrise, SuperBird, Super Fast Browser, Sushi Browser, surf, Stargon, START Internet Browser, Steam In-Game Overlay, Streamy, Swiftfox, Seznam Browser, T+Browser, T-Browser, t-online.de Browser, Tao Browser, TenFourFox, Tenta Browser, Tizen Browser, Tungsten, ToGate, TweakStyle, TV Bro, UBrowser, UC Browser, UC Browser HD, UC Browser Mini, UC Browser Turbo, UR Browser, Uzbl, Venus Browser, Vivaldi, vivo Browser, Vision Mobile Browser, VMware AirWatch, Wear Internet Browser, Web Explorer, WebPositive, Waterfox, Whale Browser, wOSBrowser, WeTab Browser, Yahoo! Japan Browser, Yandex Browser, Yandex Browser Lite, Yaani Browser, Yolo Browser, xStand, Xiino, Xvast, Zetakey, Zvu

List of detected browser engines:

WebKit, Blink, Trident, Text-based, Dillo, iCab, Elektra, Presto, Gecko, KHTML, NetFront, Edge, NetSurf, Servo, Goanna, EkiohFlow

List of detected libraries:

aiohttp, Akka HTTP, Aria2, C++ REST SDK, curl, Embarcadero URI Client, Faraday, Go-http-client, Google HTTP Java Client, GRequests, Guzzle (PHP HTTP Client), gvfs, HTTPie, HTTP_Request2, Jakarta Commons HttpClient, Java, libdnf, LUA OpenResty NGINX, Mechanize, Mikrotik Fetch, Node Fetch, OkHttp, Perl, Perl REST::Client, Postman Desktop, Python Requests, Python urllib, ReactorNetty, REST Client for Ruby, RestSharp, ScalaJ HTTP, uclient-fetch, urlgrabber (yum), uTorrent, Wget, WinHttp WinHttpRequest, WWW-Mechanize

List of detected media players:

Audacious, Banshee, Boxee, Clementine, Deezer, Downcast, FlyCast, Foobar2000, foobar2000, Google Podcasts, HTC Streaming Player, iTunes, Kodi, MediaMonkey, Miro, MPlayer, mpv, Music Player Daemon, NexPlayer, Nightingale, QuickTime, Songbird, SONOS, Sony Media Go, Stagefright, SubStream, VLC, Winamp, Windows Media Player, XBMC

List of detected mobile apps:

1Password, 2tch, Adobe Creative Cloud, Adobe Synchronizer, Aha Radio 2, AIDA64, Alexa Media Player, AliExpress, AndroidDownloadManager, AntennaPod, Apple News, Avid Link, Background Intelligent Transfer Service, Baidu Box App, Battle.net, BB2C, BBC News, BetBull, BeyondPod, Bible KJV, Binance, BingWebApp, Bitsboard, Blackboard, Blitz, Blue Proxy, BlueStacks, Bookshelf, Bose Music, bPod, CastBox, Castro, Castro 2, CCleaner, CGN, ChMate, Chrome Update, Ciisaa, Clovia, COAF SMART Citizen, Copied, Cortana, Covenant Eyes, CPU-Z, CrosswalkApp, DevCasts, DeviantArt, DingTalk, Discord, DoggCatcher, douban App, Downcast, Dr. Watson, Edge Update, Emby Theater, Epic Games Launcher, ESET Remote Administrator, eToro, Evolve Podcast, Facebook, Facebook Audience Network, Facebook Groups, Facebook Messenger, Facebook Messenger Lite, FeedR, Flipboard App, Flipp, Gaana, Git, GitHub Desktop, GlobalProtect, GoNative, Google Fiber TV, Google Go, Google Play Newsstand, Google Plus, Google Podcasts, Google Search App, Google Tag Manager, HandBrake, HeyTapBrowser, Hik-Connect, HP Smart, iCatcher, Instabridge, Instacast, Instagram App, Instapaper, JaneStyle, Jungle Disk, KakaoTalk, Keeper Password Manager, Kik, Landis+Gyr AIM Browser, Line, LinkedIn, Logi Options+, MetaTrader, Microsoft Office $1, Microsoft Office Mobile, Microsoft OneDrive, Microsoft Outlook, My World, Naver, Netflix, NewsArticle App, Nextcloud, NPR One, NTV Mobil, NuMuKi Browser, Odnoklassniki, OfferUp, Opal Travel, Opera News, Overcast, Paint by Number, Pandora, Papers, Pic Collage, Pinterest, Player FM, Pocket Casts, Podbean, Podcast & Radio Addict, Podcaster, Podcast Republic, Podcasts, Podcat, Podcatcher Deluxe, Podimo, Podkicker$1, PowerShell, Procast, qBittorrent, QQMusic, QuickCast, RadioPublic, Rave Social, Razer Synapse, rekordbox, Roblox, RoboForm, Rocket Chat, RSSRadio, Samsung Magician, Shopee, ShowMe, Sina Weibo, Siri, Skyeng Teachers, Skype for Business, Slack, Snapchat, SogouSearch App, SPORT1, Streamlabs OBS, Strimio, Swoot, Teams, The Wall Street Journal, Theyub, Thunder, tieba, TikTok, TopBuzz, TradingView, TuneIn Radio, TuneIn Radio Pro, TVirl, twinkle, Twitter, U-Cursos, Unibox, UnityPlayer, Viber, Visual Studio Code, Vuhuv, Wattpad, WebDAV, WeChat, WeChat Share Extension, WhatsApp, Whisper, WH Questions, Windows CryptoAPI, Windows Delivery Optimization, Windows Push Notification Services, Windows Update Agent, Wireshark, Wirtschafts Woche, Word Cookies!, Y8 Browser, Yahoo! Japan, YakYak, Yandex, Yelp Mobile, YouTube, Zalo, ZEPETO, Zoho Chat and mobile apps using AFNetworking

List of detected PIMs (personal information manager):

Airmail, Barca, Basecamp, BathyScaphe, DAVdroid, Evernote, Franz, JaneView, Live5ch, Lotus Notes, MailBar, Mailbird, Mailspring, Microsoft Outlook, Notion, Outlook Express, Postbox, Raindrop.io, Rambox Pro, SeaMonkey, The Bat!, Thunderbird, Windows Mail

List of detected feed readers:

Akregator, Apple PubSub, BashPodder, Breaker, FeedDemon, Feeddler RSS Reader, gPodder, JetBrains Omea Reader, Liferea, NetNewsWire, Newsbeuter, NewsBlur, NewsBlur Mobile App, PritTorrent, Pulp, QuiteRSS, ReadKit, Reeder, RSS Bandit, RSS Junkie, RSSOwl, Stringer

List of brands with detected devices:

2E, 3GNET, 3GO, 3Q, 4Good, 4ife, 7 Mobile, 360, 8848, A1, Accent, Ace, Acer, Acteck, Adronix, Advan, Advance, AfriOne, AGM, AG Mobile, Ainol, Airness, AIRON, Airties, AIS, Aiuto, Aiwa, Akai, AKIRA, Alba, Alcatel, Alcor, ALDI NORD, ALDI SÜD, Alfawise, Aligator, AllCall, AllDocube, Allview, Allwinner, Altech UEC, Altice, altron, Amazon, AMCV, AMGOO, Amigoo, Amoi, Andowl, Anker, Anry, ANS, AOC, Aocos, AOpen, Aoson, AOYODKG, Apple, Archos, Arian Space, Ark, ArmPhone, Arnova, ARRIS, Artel, Artizlee, Asano, Asanzo, Ask, Aspera, Assistant, Astro, Asus, AT&T, Atom, Atvio, Audiovox, AURIS, Avenzo, AVH, Avvio, Awow, Axioo, Axxion, Azumi Mobile, BangOlufsen, Barnes & Noble, BBK, BB Mobile, BDF, Becker, Beeline, Beelink, Beetel, Bellphone, BenQ, BenQ-Siemens, Benzo, Beyond, Bezkam, BGH, Bigben, BIHEE, BilimLand, Billion, BioRugged, Bird, Bitel, Bitmore, Bkav, Black Bear, Black Fox, Blackview, Blaupunkt, Bleck, Blloc, Blow, Blu, Bluboo, Bluebird, Bluedot, Bluegood, Bluewave, BMAX, Bmobile, Bobarry, bogo, Boway, bq, Brandt, Bravis, BrightSign, Brondi, BS Mobile, Bubblegum, Bundy, Bush, CAGI, Camfone, Canal Digital, Capitel, Captiva, Carrefour, Casio, Casper, Cat, Cavion, Celcus, Celkon, Cell-C, CellAllure, Cellution, Centric, CG Mobile, CGV, Changhong, Cherry Mobile, Chico Mobile, China Mobile, Chuwi, Claresta, Clarmin, Clementoni, Cloud, Cloudfone, Cloudpad, Clout, CnM, Cobalt, Coby Kyros, Colors, Comio, Compal, Compaq, ComTrade Tesla, Concord, ConCorde, Condor, Connectce, Connex, Conquest, Contixo, Coolpad, CORN, Cosmote, Covia, Cowon, CreNova, Crescent, Cricket, Crius Mea, Crony, Crosscall, Cube, CUBOT, CVTE, Cyrus, Daewoo, Danew, Datalogic, Datamini, Datang, Datawind, Datsun, Dazen, Dbtel, Dell, Denver, Desay, DeWalt, DEXP, Dialog, Dicam, Digi, Digicel, DIGIFORS, Digihome, Digiland, Digma, DING DING, DISH, Ditecma, Diva, Divisat, DIXON, DMM, DNS, DoCoMo, Doffler, Dolamee, Doogee, Doopro, Doov, Dopod, Doro, Dragon Touch, Droxio, Dune HD, E-Boda, E-Ceros, E-tel, Eagle, Easypix, EBEST, Echo Mobiles, ECON, ECS, EE, Einstein, EKO, Eks Mobility, EKT, ELARI, Electroneum, ELECTRONIA, Elekta, Element, Elenberg, Elephone, Eltex, Energizer, Energy Sistem, Engel, Enot, Epik One, Epson, Ergo, Ericsson, Ericy, Erisson, Essential, Essentielb, eSTAR, Eton, eTouch, Etuline, Eurostar, Evercoss, Evertek, Evolio, Evolveo, EvroMedia, EWIS, EXCEED, Exmart, ExMobile, EXO, Explay, Extrem, Ezio, Ezze, F&U, F2 Mobile, F150, Facebook, Fairphone, Famoco, Fantec, FaRao Pro, FarEasTone, Fengxiang, Fero, FiGO, FiiO, FinePower, Finlux, FireFly Mobile, FISE, Fly, FLYCAT, FMT, FNB, FNF, Fondi, Fonos, FORME, Formuler, Forstar, Fortis, Fourel, Four Mobile, Foxconn, Freetel, Fuego, Fujitsu, G-TiDE, G-Touch, Galaxy Innovations, Garmin-Asus, Gateway, Gemini, General Mobile, Genesis, GEOFOX, Geotel, Geotex, GFive, Ghia, Ghong, Ghost, Gigabyte, Gigaset, Gini, Ginzzu, Gionee, Globex, Glofiish, GLX, GOCLEVER, Gocomma, GoGEN, Gol Mobile, Goly, Gome, GoMobile, Google, Goophone, Gooweel, Gradiente, Grape, Gree, Greentel, Gresso, Gretel, Grundig, Hafury, Haier, HannSpree, Hardkernel, Hasee, Helio, Hezire, Hi, Hi-Level, High Q, Highscreen, HiMax, Hipstreet, Hisense, Hitachi, Hitech, Hoffmann, Hometech, Homtom, Honeywell, Hoozo, Horizon, Hosin, Hotel, Hotwav, How, HP, HTC, Huadoo, Huavi, Huawei, Humax, Hurricane, Huskee, Hyrican, Hyundai, Hyve, i-Cherry, i-Joy, i-mate, i-mobile, iBall, iBerry, iBrit, IconBIT, iDroid, iGet, iHunt, Ikea, IKI Mobile, iKoMo, IKU Mobile, iLA, iLife, iMan, iMars, IMO Mobile, Impression, INCAR, Inch, Inco, iNew, Infinix, InFocus, InfoKit, Inkti, InnJoo, Innos, Innostream, Inoi, INQ, Insignia, Intek, Intex, Invens, Inverto, Invin, iOcean, iOutdoor, iPro, iQ&T, IQM, Irbis, Iris, iRola, iRulu, iSWAG, IT, iTel, iTruck, IUNI, iVA, iView, iVooMi, ivvi, iZotron, JAY-Tech, Jeka, Jesy, JFone, Jiake, Jiayu, Jinga, Jivi, JKL, Jolla, Juniper Systems, Just5, JVC, K-Touch, Kaan, Kaiomy, Kalley, Kanji, Karbonn, Kata, KATV1, Kazam, Kazuna, KDDI, Kempler & Strauss, Keneksi, Kenxinda, Kiano, Kingsun, KINGZONE, Kiowa, Kivi, Klipad, Kocaso, Kodak, Kogan, Komu, Konka, Konrow, Koobee, Koolnee, Kooper, KOPO, Koridy, KREZ, KRIP, KRONO, Krüger&Matz, KT-Tech, KUBO, Kuliao, Kult, Kumai, Kurio, Kvant, Kyocera, Kyowon, Kzen, L-Max, LAIQ, Land Rover, Landvo, Lanix, Lark, Laurus, Lava, LCT, Leader Phone, Leagoo, Leben, Ledstar, LeEco, Leff, LEMFO, Lemhoov, Lenco, Lenovo, Leotec, Le Pan, Lephone, Lesia, Lexand, Lexibook, LG, Liberton, Lifemaxx, Lingwin, Linnex, Linsar, Loewe, Logic, Logicom, Loview, LT Mobile, Lumigon, Lumus, Luna, Luxor, LYF, M-Horse, M-Tech, M.T.T., M4tel, MAC AUDIO, Macoox, Mafe, Magnus, Majestic, Malata, Manhattan, Mann, Manta Multimedia, Mantra, Mara, Masstel, Matrix, Maxcom, Maximus, Maxtron, MAXVI, Maxwest, Maze, Maze Speed, MDC Store, meanIT, Mecer, Mecool, Mediacom, MediaTek, Medion, MEEG, MegaFon, Meitu, Meizu, Melrose, Memup, Metz, MEU, MicroMax, Microsoft, Minix, Mintt, Mio, Miray, Mito, Mitsubishi, Mitsui, MIVO, MIXC, MiXzo, MLLED, MLS, Mobicel, MobiIoT, Mobiistar, Mobiola, Mobistel, MobiWire, Mobo, Modecom, Mofut, Motorola, Movic, mPhone, Mpman, MSI, MStar, MTC, MTN, Multilaser, MYFON, MyGica, Mymaga, MyPhone, Myria, Myros, Mystery, MyTab, MyWigo, Nabi, Naomi Phone, National, Navcity, Navitech, Navitel, Navon, NEC, Necnot, Neffos, Neomi, Neon IQ, Netgear, NeuImage, New Balance, Newgen, Newland, Newman, Newsday, NewsMy, NEXBOX, Nexian, NEXON, Nextbit, NextBook, NextTab, NGM, NG Optics, Nikon, Nintendo, NOA, Noain, Nobby, Noblex, NOBUX, Nokia, Nomi, Nomu, Nordmende, NorthTech, Nos, Nous, Novex, NuAns, Nubia, NUU Mobile, Nuvo, Nvidia, NYX Mobile, O+, O2, Oale, OASYS, Obi, Oculus, Odys, OINOM, Ok, Okapia, OKSI, OKWU, Onda, OnePlus, Onix, ONN, ONYX BOOX, OpelMobile, Openbox, OPPO, Opsson, Orange, Orbic, Ordissimo, Ouki, Oukitel, OUYA, Overmax, Ovvi, Owwo, Oysters, Oyyu, OzoneHD, P-UP, Packard Bell, Paladin, Palm, Panacom, Panasonic, Pantech, Parrot Mobile, PCBOX, PCD, PCD Argentina, PEAQ, Pendoo, Pentagram, Perfeo, Phicomm, Philco, Philips, Phonemax, phoneOne, Pico, Pioneer, PiPO, Pixela, Pixelphone, Pixus, Planet Computers, Ployer, Plum, Pluzz, PocketBook, POCO, Point of View, Polar, PolarLine, Polaroid, PolyPad, Polytron, Pomp, Poppox, Positivo, Positivo BGH, PPTV, Premio, Prestigio, Primepad, Primux, Prixton, PROFiLO, Proline, ProScan, Protruly, ProVision, PULID, Q-Touch, Q.Bell, Qilive, QMobile, Qnet Mobile, Qtek, Quantum, Qubo, Quechua, Qumo, R-TV, Rakuten, Ramos, Raspberry, Ravoz, Razer, RCA Tablets, Reach, Readboy, Realme, RED, Reeder, REGAL, Revo, Rikomagic, RIM, Rinno, Ritmix, Ritzviva, Riviera, Rivo, Roadrover, Rokit, Roku, Rombica, Ross&Moor, Rover, RoverPad, RoyQueen, RT Project, RugGear, Ruio, Runbo, Ryte, S-TELL, Saba, Safaricom, Sagem, Salora, Samsung, Sanei, Sansui, Santin, Sanyo, Savio, SCBC, Schneider, Seatel, Seeken, SEG, Sega, Selenga, Selevision, Selfix, SEMP TCL, Sencor, Sendo, Senkatel, Senseit, Senwa, Seuic, SFR, Sharp, Shift Phones, Shtrikh-M, Shuttle, Sico, Siemens, Sigma, Silelis, Silent Circle, Simbans, Simply, Singtech, Siragon, Sirin labs, SKG, Sky, Skyworth, Smadl, Smailo, Smart, Smartab, SmartBook, SMARTEC, Smart Electronic, Smartfren, Smartisan, Smooth Mobile, Smotreshka, Softbank, SOLE, SOLO, Solone, Sonim, SONOS, Sony, Sony Ericsson, Soundmax, Soyes, Spark, SPC, Spectralink, Spectrum, Spice, Sprint, SQOOL, Star, Starlight, Starmobile, Starway, Starwind, STF Mobile, STG Telecom, STK, Stonex, Storex, StrawBerry, STRONG, Stylo, Subor, Sugar, Sumvision, Sunny, Sunstech, SunVan, Sunvell, SUNWIND, SuperSonic, SuperTab, Supra, Suzuki, Swipe, SWISSMOBILITY, Swisstone, SWTV, Symphony, Syrox, T-Mobile, Taiga System, Takara, Tambo, Tanix, TB Touch, TCL, TD Systems, Technicolor, Technika, TechniSat, TechnoTrend, TechPad, Techwood, Teclast, Tecno Mobile, TEENO, Teknosa, Tele2, Telefunken, Telego, Telenor, Telia, Telit, Telpo, Tesco, Tesla, Tetratab, teXet, ThL, Thomson, Thuraya, TIANYU, Time2, Timovi, Tinai, Tinmo, TiPhone, TOKYO, Tolino, Tone, Tooky, Topelotek, Top House, Toplux, Topway, Torex, Toshiba, Touchmate, Transpeed, TrekStor, Trevi, Trident, Trifone, Trio, Tronsmart, True, True Slim, TTEC, Tunisie Telecom, Turbo, Turbo-X, TurboKids, TurboPad, TVC, TWM, Twoe, TWZ, Tymes, U.S. Cellular, Ugoos, Uhans, Uhappy, Ulefone, Umax, UMIDIGI, Unihertz, Unimax, Uniscope, UNIWA, Unknown, Unnecto, Unonu, Unowhy, Urovo, UTime, UTOK, UTStarcom, UZ Mobile, v-mobile, VAIO, Vargo, Vastking, VAVA, VC, Vega, Venso, Verico, Verizon, Vernee, Vertex, Vertu, Verykool, Vesta, Vestel, Vexia, VGO TEL, Videocon, Videoweb, ViewSonic, Vinga, Vinsoc, Vipro, Virzo, Vision Touch, Vitelcom, Viumee, Vivax, Vivo, VIWA, Vizio, VK Mobile, VKworld, Vodacom, Vodafone, Vonino, Vontar, Vorago, Vorke, Voto, VOX, Voxtel, Voyo, Vsmart, Vsun, Vulcan, VVETIME, Walton, WE, Web TV, Weimei, WellcoM, WELLINGTON, Western Digital, Westpoint, Wexler, Wieppo, Wigor, Wiko, Wileyfox, Winds, Wink, Winmax, Winnovo, Wintouch, Wiseasy, WIWA, Wizz, Wolder, Wolfgang, Wolki, Wonu, Woo, Wortmann, Woxter, X-BO, X-TIGI, X-View, X.Vision, XGIMI, Xgody, Xiaolajiao, Xiaomi, Xion, Xolo, Xoro, Xshitou, Xtouch, Xtratech, Yandex, Yarvik, YASIN, Yes, Yezz, Yoka TV, Yota, Ytone, Yu, Yuandao, YUHO, Yuno, Yusun, Yxtel, Zaith, Zatec, Zebra, Zeemi, Zen, Zenek, Zentality, Zfiner, ZH&K, Zidoo, ZIFRO, Ziox, Zonda, Zopo, ZTE, Zuum, Zync, ZYQ, öwn

List of detected bots:

360Spider, Aboundexbot, Acoon, Adbeat, AddThis.com, ADMantX, ADmantX Service Fetcher, Adsbot, aHrefs Bot, Alexa Crawler, Alexa Site Audit, Amazon Bot, Amazon Route53 Health Check, Amorank Spider, Analytics SEO Crawler, ApacheBench, Applebot, AppSignalBot, Arachni, archive.org bot, ArchiveBox, Ask Jeeves, AspiegelBot, Awario, Awario, Backlink-Check.de, BacklinkCrawler, Baidu Spider, Barkrowler, BazQux Reader, BDCbot, Better Uptime Bot, BingBot, BitlyBot, Blekkobot, BLEXBot Crawler, Bloglovin, Blogtrottr, BoardReader, BoardReader Blog Indexer, Bountii Bot, BrandVerity, Browsershots, BUbiNG, Buck, BuiltWith, Butterfly Robot, Bytespider, CareerBot, Castro 2, Catchpoint, CATExplorador, ccBot crawler, CensysInspect, Charlotte, Choosito, Cliqzbot, CloudFlare Always Online, CloudFlare AMP Fetcher, Cloudflare Diagnostics, Cocolyzebot, Collectd, colly, CommaFeed, Comscore, ContentKing, Cookiebot, CSS Certificate Spider, Cốc Cốc Bot, Datadog Agent, DataForSeoBot, datagnionbot, Datanyze, Dataprovider, DataXu, Daum, Dazoobot, Discobot, Discord Bot, Domain Re-Animator Bot, Domains Project, DotBot, Dotcom Monitor, DuckDuckGo Bot, Easou Spider, eCairn-Grabber, EMail Exractor, EmailWolf, Embedly, evc-batch, ExaBot, ExactSeek Crawler, Expanse, Ezooms, eZ Publish Link Validator, Facebook External Hit, Feedbin, FeedBurner, Feedly, Feedspot, Feed Wrangler, Fever, Findxbot, Flipboard, FreshRSS, GDNP, Generic Bot, Generic Bot, Genieo Web filter, Gigablast, Gigabot, Gluten Free Crawler, Gmail Image Proxy, Gobuster, Goo, Googlebot, Google Cloud Scheduler, Google Favicon, Google PageSpeed Insights, Google Partner Monitoring, Google Search Console, Google Stackdriver Monitoring, Google StoreBot, Google Structured Data Testing Tool, Gowikibot, Grammarly, Grapeshot, GTmetrix, Hatena Favicon, Heart Rails Capture, Heritrix, Heureka Feed, HTTPMon, httpx, HuaweiWebCatBot, HubPages, HubSpot, ICC-Crawler, ichiro, IDG/IT, IIS Site Analysis, Inktomi Slurp, inoreader, IP-Guide Crawler, IPS Agent, JungleKeyThumbnail, K6, Kaspersky, KomodiaBot, Kouio, l9tcpid, Larbin web crawler, LCC, Let's Encrypt Validation, Lighthouse, Linkdex Bot, LinkedIn Bot, LinkpadBot, LinkPreview, LTX71, LumtelBot, Lycos, Magpie-Crawler, MagpieRSS, Mail.Ru Bot, masscan, Mastodon Bot, Meanpath Bot, Mediatoolkit Bot, MegaIndex, MetaInspector, MetaJobBot, MicroAdBot, Mixrank Bot, MJ12 Bot, Mnogosearch, MojeekBot, Monitor.Us, MTRobot, Munin, MuscatFerret, Nagios check_http, NalezenCzBot, nbertaupete95, Neevabot, Netcraft Survey Bot, netEstate, NetLyzer FastProbe, NetResearchServer, NetSystemsResearch, Netvibes, NewsBlur, NewsGator, Nimbostratus Bot, NLCrawler, Nmap, Notify Ninja, Nutch-based Bot, Nuzzel, oBot, Octopus, Odnoklassniki Bot, Omgili bot, Openindex Spider, OpenLinkProfiler, OpenWebSpider, Orange Bot, Outbrain, PagePeeker, PageThing, PaperLiBot, parse.ly, Petal Bot, Phantomas, PHP Server Monitor, Picsearch bot, PingAdmin.Ru, Pingdom Bot, Pinterest, PiplBot, Plukkie, PocketParser, Pompos, PritTorrent, Project Resonance, PRTG Network Monitor, QuerySeekerSpider, Quora Bot, Quora Link Preview, Qwantify, Rainmeter, RamblerMail Image Proxy, Reddit Bot, Riddler, Robozilla, RocketMonitorBot, Rogerbot, ROI Hunter, RSSRadio Bot, Ryowl, SabsimBot, SafeDNSBot, Scooter, ScoutJet, Scrapy, Screaming Frog SEO Spider, ScreenerBot, Seekport, Semantic Scholar Bot, Semrush Bot, Sensika Bot, Sentry Bot, Seobility, SEOENGBot, SEOkicks, SEOkicks-Robot, seolyt, Seoscanners.net, Serendeputy Bot, serpstatbot, Server Density, Seznam Bot, Seznam Email Proxy, Seznam Zbozi.cz, ShopAlike, Shopify Partner, ShopWiki, SilverReader, SimplePie, SISTRIX Crawler, SISTRIX Optimizer, Site24x7 Website Monitoring, Siteimprove, SitemapParser-VIPnytt, SiteSucker, Sixy.ch, Skype URI Preview, Slackbot, SMTBot, Snapchat Proxy, Sogou Spider, Soso Spider, Sparkler, Speedy, Spinn3r, Spotify, Sprinklr, Sputnik Bot, Sputnik Favicon Bot, Sputnik Image Bot, sqlmap, SSL Labs, Startpagina Linkchecker, StatusCake, Superfeedr Bot, SurdotlyBot, Survey Bot, Tarmot Gezgin, TelegramBot, The Knowledge AI, theoldreader, ThinkChaos, TinEye Crawler, Tiny Tiny RSS, TLSProbe, TraceMyFile, Trendiction Bot, Turnitin, TurnitinBot, TweetedTimes Bot, Tweetmeme Bot, Twingly Recon, Twitterbot, UkrNet Mail Proxy, UniversalFeedParser, Uptimebot, Uptime Robot, URLAppendBot, Vagabondo, Velen Public Web Crawler, Vercel Bot, VeryHip, Visual Site Mapper Crawler, VK Share Button, W3C CSS Validator, W3C I18N Checker, W3C Link Checker, W3C Markup Validation Service, W3C MobileOK Checker, W3C Unified Validator, Wappalyzer, WebbCrawler, WebDataStats, Weborama, WebPageTest, WebSitePulse, WebThumbnail, WellKnownBot, WeSEE:Search, WeViKaBot, WhatCMS, WikiDo, Willow Internet Crawler, WooRank, WooRank, WordPress, Wotbox, XenForo, YaCy, Yahoo! Cache System, Yahoo! Japan BRW, Yahoo! Link Preview, Yahoo! Mail Proxy, Yahoo! Slurp, Yahoo Gemini, YaK, Yandex Bot, Yeti/Naverbot, Yottaa Site Monitor, Youdao Bot, Yourls, Yunyun Bot, Zao, Ze List, zgrab, Zookabot, ZoominfoBot, ZumBot

Updating from Matomo project

  1. Clone the Matomo project.
  2. Iterate through the various commits and copy the fixture files with the commands below.
  3. Review logic changes in the PHP files and implement them in the Python code.
  4. Run the tests and fix the ones that fail.
export upstream=/path/to/cloned/matomo/device-detector
export pdd=/path/to/python/ported/device_detector

cp $upstream/regexes/device/*.yml $pdd/device_detector/regexes/upstream/device/
cp $upstream/regexes/client/*.yml $pdd/device_detector/regexes/upstream/client/
cp $upstream/regexes/*.yml $pdd/device_detector/regexes/upstream/
cp $upstream/Tests/fixtures/* $pdd/device_detector/tests/fixtures/upstream/
cp $upstream/Tests/Parser/Client/fixtures/* $pdd/device_detector/tests/parser/fixtures/upstream/client/
cp $upstream/Tests/Parser/Device/fixtures/* $pdd/device_detector/tests/parser/fixtures/upstream/device/

device_detector's People

Contributors

adq avatar alexeypetroff avatar anatoliifetisov avatar chedidelias avatar deepsourcebot avatar findus23 avatar thinkwelltwd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

device_detector's Issues

unable to recognize salesforcemobilesdk

Thanks for this great package. Just found it can't recognize salesforecemobilesdk. please find the 2 example below:
SalesforceMobileSDK/7.0.0 android mobile/8.0.0 (VS996) Salesforce1/220.3(220030100) Native uid_48de40dfc42c7f9c ftr_AI.UA Cordova/7.1.2 Hybrid SalesforceMobileSDK/7.0.0 android mobile/8.0.0 (VS996) Salesforce1/220.3(220030100) Native uid_48de40dfc42c7f9c
SalesforceMobileSDK/6.1.0 iOS/12.3.1 (iPhone) Chatter/18.3(6137609) Hybrid uid_8468E465-2EC2-4B46-90B5-F83D7F0028FD ftr_GS.PN.UA Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 iPhone/12.3.1
Thanks

Encoding problems on Windows computers

On version 0.9 worked ok, but on 0.10 i have a following exception when i try to parse user_agent string (the "x" variable):

In [1]: x = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, 
   ...:  like Gecko) Chrome/83.0.4103.61 Safari/537.36'

In [2]: from device_detector import DeviceDetector

In [3]: result1 = DeviceDetector(x).parse()
---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)       
<ipython-input-3-55b0fb999d44> in <module>
----> 1 result1 = DeviceDetector(x).parse()

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\site-packages\device_detector\device_detector.py in parse(self)
    231 
    232         if not self.skip_bot_detection:
--> 233             self.parse_bot()
    234             if self.is_bot():
    235                 return self.set_parse_cache()

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\site-packages\device_detector\device_detector.py in parse_bot(self)
    310         """
    311         if not self.skip_bot_detection and not self.bot:
--> 312             self.bot = Bot(self.user_agent, self.ua_hash, self.ua_spaceless).parse()
    313             self.all_details['bot'] = self.bot.ua_data
    314

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\site-packages\device_detector\parser\parser.py in parse(self)
     85             return self
     86
---> 87         self._parse()
     88         self.extract_details()
     89 

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\site-packages\device_detector\parser\parser.py in _parse(self)
     69     def _parse(self) -> None:
     70         """Override on subclasses if custom parsing is required"""
---> 71         for ua_data in self.regex_list:
     72             match = self._check_regex(ua_data['regex'])
     73             if match:

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\site-packages\device_detector\yaml_loader.py in regex_list(self)
     79
     80         for fixture in self.fixture_files:
---> 81             regexes.extend(self.yaml_to_list('regexes/{}'.format(fixture)))
     82
     83         for regex in regexes:

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\site-packages\device_detector\yaml_loader.py in yaml_to_list(self, yfile)
     61         Load yaml file to list of dicts
     62         """
---> 63         regexes = self.load_from_yaml(yfile)
     64         if isinstance(regexes, list):
     65             return regexes

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\site-packages\device_detector\yaml_loader.py in load_from_yaml(yfile)
     33         if Path('{}/{}'.format(ROOT, yfile)).exists():
     34             with open('{}/{}'.format(ROOT, yfile), 'r') as yf:
---> 35                 return yaml.load(yf, SafeLoader)
     36
     37         try:

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\site-packages\yaml\__init__.py in load(stream, Loader)
    112     loader = Loader(stream)
    113     try:
--> 114         return loader.get_single_data()
    115     finally:
    116         loader.dispose()

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\site-packages\yaml\constructor.py in get_single_data(self)
     47     def get_single_data(self):
     48         # Ensure that the stream contains a single document and construct 
it.
---> 49         node = self.get_single_node()
     50         if node is not None:
     51             return self.construct_document(node)

ext\_yaml.pyx in _yaml.CParser.get_single_node()

ext\_yaml.pyx in _yaml.CParser._compose_document()

ext\_yaml.pyx in _yaml.CParser._compose_node()

ext\_yaml.pyx in _yaml.CParser._compose_sequence_node()

ext\_yaml.pyx in _yaml.CParser._compose_node()

ext\_yaml.pyx in _yaml.CParser._compose_mapping_node()

ext\_yaml.pyx in _yaml.CParser._compose_node()

ext\_yaml.pyx in _yaml.CParser._parse_next_event()

ext\_yaml.pyx in _yaml.input_handler()

~\AppData\Local\Continuum\miniconda3\envs\bluebooster_sandbox\lib\encodings\cp1250.py in decode(self, input, final)
     21 class IncrementalDecoder(codecs.IncrementalDecoder):
     22     def decode(self, input, final=False):
---> 23         return codecs.charmap_decode(input,self.errors,decoding_table)[0] 
     24
     25 class StreamWriter(Codec,codecs.StreamWriter):

UnicodeDecodeError: 'charmap' codec can't decode byte 0x83 in position 4159: character maps to <undefined>

Python 3.7.7
Windows 10
device_detector 0.10.0

on version 0.9 there is no problem.

Looks like a problem with encoding?

Unable to detect device

device_detector is unable to detect device type for following user agents.

"Kik/13.0.0.7521 (Android 7.1.1) Mozilla/5.0 (Linux; Android 7.1.1; 6060S Build/NMF26F; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 Mobile Safari/537.36"
"Mozilla/5.0 (Linux; Android 5.1.1; 2014817 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.89 Mobile Safari/537.36"
"Mozilla/5.0 (Linux; Android 5.1.1; VS985 4G Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36"
"Mozilla/5.0 (Linux; Android 6.0.1; E0108 Build/MOB30R) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.158 Safari/537.36"
"Mozilla/5.0 (Linux; Android 6.0.1; FP2 Build/FP2-gms-18.04.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.101 Mobile Safari/537.36 (Ecosia [email protected])"
"Mozilla/5.0 (Linux; Android 6.0.1; S60 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.158 Mobile Safari/537.36"

Can't import

settings.py has *args before a variable name for the MAX_CACHE_SIZE. This is breaking import.

Can't install device_detector from pip

  Using cached https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz
Obtaining device-detector from git+git://github.com/AlexeyPetroff/device_detector.git@aea8e5d2033eb02389c014692e73a36e74994ab7#egg=device-detector (from -r rrrr.txt (line 2))
  Cloning git://github.com/AlexeyPetroff/device_detector.git (to revision aea8e5d2033eb02389c014692e73a36e74994ab7) to /home/al/venv/proj/project/srcdevice-detector
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/al/venv/proj/project/srcdevice-detector/setup.py", line 5, in <module>
        import device_detector
      File "/home/al/venv/proj/project/srcdevice-detector/device_detector/__init__.py", line 3, in <module>
        from .parser import *
      File "/home/al/venv/proj/project/srcdevice-detector/device_detector/parser/__init__.py", line 1, in <module>
        from .client import *
      File "/home/al/venv/proj/project/srcdevice-detector/device_detector/parser/client/__init__.py", line 1, in <module>
        from .base import *
      File "/home/al/venv/proj/project/srcdevice-detector/device_detector/parser/client/base.py", line 1, in <module>
        from ..parser import Parser
      File "/home/al/venv/proj/project/srcdevice-detector/device_detector/parser/parser.py", line 5, in <module>
        import yaml
    ModuleNotFoundError: No module named 'yaml'
    
    ----------------------------------------

From what I see the problem is that you are trying to import version from a file, where other imports are executed and they import pyYAML prematurely.

Can't install with pip

Hey,
I want to try your lib but I can't install with pip :(

Collecting device_detector
  Could not find a version that satisfies the requirement device_detector (from versions: )
No matching distribution found for device_detector
 ```

Thanks

self.all_details is None (?)

File "/app/main.py", line 184, in _ua

ua['device_type'] = parsed.device_type()

^^^^^^^^^^^^^^^^^^^^

File "/opt/venv/lib/python3.11/site-packages/device_detector/device_detector.py", line 560, in device_type

dt = self.all_details.get('device', {}).get('type', '')

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'get'

parsed.device attribute also returns None, but it looks like here its self.all_details that is causing the error. Thats not possible either cause I called .all_details, and it is definitely not None.

parsed = DeviceDetector(request.user_agent.string).parse()
ua = parsed.all_details
ua['device'] = parsed.device
ua['device_type'] = parsed.device_type()

The ReadMe.md references of a device_brand_name() function

The ReadMe.md references a device_brand_name() function but I can't see it anywhere in the code and calling it fails when called

    device = DeviceDetector(user_agent).parse()
    manufacturer = device.device_brand_name()

AttributeError: 'DeviceDetector' object has no attribute 'device_brand_name'

Very long parsing

Hello, and thank you for your great parser !

The only problem I'm facing is that the parsing is long, very much longer than other parsers like woothee, ua-parser or httpagentparser, BUT your results are more accurate :)

For example, with a simple script who only parse 400 lines, ua-parser made it in 1.009 seconds, and device_detector 219s.

Is there any reason ? Maybe can you look how they made it compared to you ?

Thanks a lot

ImportError occurs when I run device_detector.py

This is the resulting error.

Traceback (most recent call last):
File "device_detector.py", line 1, in
from .lazy_regex import RegexLazyIgnore
ImportError: attempted relative import with no known parent package

UnicodeDecodeError

I am trying to use the dvice detactor parser in this way:

from device_detector import DeviceDetector

 ua = 'Mozilla/5.0 (Linux; Android 6.0; 4Good Light A103 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36'
device = DeviceDetector(ua).parse()

and I'm getting the following issue :

 return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8a in position 10570: character maps to <undefined>

someone have any idea what could be the issue?

thanks

Problem with parsed data object after parsing the same user agent

In [1]: from device_detector import DeviceDetector

In [2]: user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.3 
   ...: 6 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36'

In [3]: result1 = DeviceDetector(user_agent).parse()

In [4]: result1.client.engine()
Out[4]: 'WebKit'

In [5]: result2 = DeviceDetector(user_agent).parse()

In [6]: result2.client.engine()
---------------------------------------------------------------------------       
AttributeError                            Traceback (most recent call last)       
<ipython-input-6-ac90275beaa1> in <module>
----> 1 result2.client.engine()

AttributeError: 'NoneType' object has no attribute 'engine'

In [7]: user_agent2 = user_agent + '1'

In [8]: result3 = DeviceDetector(user_agent2).parse()

In [9]: result3.client.engine()
Out[9]: 'WebKit'

If i parse the same user_agent again the "client" object is None

Python 3.7.7
device_detector=0.9.0

The following UAs crash the library (0.8 from pip)

If I decode any of the following UAs, I get the following error:

File "/usr/lib/python3.7/site-packages/device_detector/device_detector.py", line 237, in parse
self.parse_client()
File "/usr/lib/python3.7/site-packages/device_detector/device_detector.py", line 267, in parse_client
app_id = app_idx.extract().get('app_id', '')
File "/usr/lib/python3.7/site-packages/device_detector/parser/extractors.py", line 189, in extract
details = self.normalized_app_ids().get(app_id.lower(), {'app_id': app_id})
AttributeError: 'list' object has no attribute 'get'

Example UAs causing this:

IMAtvOS/t.3.8.0 tvOS/12.3 com.wetv.WEtviPhoneApp/2.0.94
tv.accedo.hgtv/3.3.1 (Linux;Android 5.1.1) ExoPlayerLib/2.5.4
com.hgtv.watcher/3.4.3 (Linux;Android 8.0.0) ExoPlayerLib/2.5.4
tv.accedo.foodnetwork/3.4.3 (Linux;Android 5.1.1) ExoPlayerLib/2.5.4

Example code:

from device_detector import DeviceDetector
d = DeviceDetector('IMAtvOS/t.3.8.0 tvOS/12.3 com.wetv.WEtviPhoneApp/2.0.94').parse()
device_detector/appids/secondary.yml does not exist
device_detector/appids/ignored.yml does not exist
device_detector/appids/normalized.yml does not exist
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.7/site-packages/device_detector/device_detector.py", line 237, in parse
self.parse_client()
File "/usr/lib/python3.7/site-packages/device_detector/device_detector.py", line 267, in parse_client
app_id = app_idx.extract().get('app_id', '')
File "/usr/lib/python3.7/site-packages/device_detector/parser/extractors.py", line 189, in extract
details = self.normalized_app_ids().get(app_id.lower(), {'app_id': app_id})
AttributeError: 'list' object has no attribute 'get'

is_bot() returns True then False for the same user agent

Hello,

I've noticed that the first time, is_bot() will return True, then False the next times for the same user agent.

With this simple script you will see :

from device_detector import DeviceDetector

user_agent = "Mozilla/5.0 (compatible; CloudFlare-AlwaysOnline/1.0; +http://www.cloudflare.com/always-online) AppleWebKit/534.34"

parsed = DeviceDetector(user_agent).parse()
print(parsed.is_bot()) #True
parsed = DeviceDetector(user_agent).parse()
print(parsed.is_bot()) #False

A cache problem ?

Maybe it's not only is_bot() but os_name(), os_version(), etc. that returns incorrect values too.

Thanks

Running on raspberry pi uses 100% cpu and takes 1 minute to complete

I am using this in a project of mine and started seeing cpu usage go through the roof on a raspberry pi 3b+
I need to detect this on every web request to determine which flask template to use for mobile vs desktop.
Unfortunately, it takes about 1 minute to run parse()

I have written a simple reproducing script here:

from device_detector import DeviceDetector

user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
print(f"user agent '{user_agent}'")
device = DeviceDetector(user_agent).parse()
print(f"device {device}")
print(f"is mobile? {device.is_mobile()}")

Running this

(.aprsd-venv) pi@digipi:~/aprsd $ time python dd.py
user agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
device Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
is mobile? False

real	0m52.678s
user	0m52.430s
sys	0m0.100s

System info

(.aprsd-venv) pi@digipi:~/aprsd $ python --version
Python 3.9.2
(.aprsd-venv) pi@digipi:~/aprsd $ uname -a
Linux digipi 5.15.61-v7+ #1579 SMP Fri Aug 26 11:10:59 BST 2022 armv7l GNU/Linux
(.aprsd-venv) pi@digipi:~/aprsd $ cat /etc/issue
Raspbian GNU/Linux 11 \n \l
(.aprsd-venv) pi@digipi:~/aprsd $ cat /proc/cpuinfo
processor	: 0
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 76.80
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 1
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 76.80
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 2
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 76.80
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 3
model name	: ARMv7 Processor rev 4 (v7l)
BogoMIPS	: 76.80
Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

Hardware	: BCM2835
Revision	: a02082
Serial		: 0000000099360b7a
Model		: Raspberry Pi 3 Model B Rev 1.2

is_bot() returns True then False for the same user agent

Hello,

I've noticed that the first time, is_bot() will return True, then False the next times for the same user agent.

With this simple script you will see :

from device_detector import DeviceDetector

user_agent = "Mozilla/5.0 (compatible; CloudFlare-AlwaysOnline/1.0; +http://www.cloudflare.com/always-online) AppleWebKit/534.34"

parsed = DeviceDetector(user_agent).parse()
print(parsed.is_bot())
parsed = DeviceDetector(user_agent).parse()
print(parsed.is_bot())

A cache problem ?

Maybe it's not only is_bot() but os_name(), os_version(), etc. that returns incorrect values too.

Thanks

ZeroDivisionError when parsing some strings

Our system tripped on the string "]]>><". Trying to parse it resulted in the following exception:

ZeroDivisionError: division by zero
  File "device_detector/device_detector.py", line 241, in parse
    self.parse_client()
  File "device_detector/device_detector.py", line 274, in parse_client
    parser = Parser(self.user_agent, self.ua_hash, self.ua_spaceless).parse()
  File "device_detector/parser/parser.py", line 87, in parse
    self._parse()
  File "device_detector/parser/client/extractor_whole_name.py", line 64, in _parse
    if self.discard_name() or not self.is_name_length_valid():
  File "device_detector/parser/client/base.py", line 134, in discard_name
    return self.is_name_mostly_numeric()
  File "device_detector/parser/client/base.py", line 172, in is_name_mostly_numeric
    return alphabetic_chars / len(app_no_punc) < .5

Question about yml updates

Hello (it's me again),

Since your lib is a port of an original project, how do you manage if this project updates the regexes in the yml files ? Your yml files will be outdated ?
Is this somehow possible to include most up to date files ?
Thanks

Regexp error: look-behind requires fixed-width pattern

On Windows 10, reproduced art both Python 3.6 and 3.7:

>>> from device_detector import DeviceDetector
>>> ua = 'Mozilla/5.0 (Linux; Android 4.3; C5502 Build/10.4.1.B.0.101) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.136 Mobile Safari/537.36'
device = DeviceDetector(ua).parse()
>>> device = DeviceDetector(ua).parse()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "c:\pythons\python37\lib\site-packages\device_detector\device_detector.py", line 213, in parse
    self.parse_bot()
  File "c:\pythons\python37\lib\site-packages\device_detector\device_detector.py", line 272, in parse_bot
    self.bot = Bot(self.user_agent).parse()
  File "c:\pythons\python37\lib\site-packages\device_detector\parser\parser.py", line 89, in parse
    self._parse()
  File "c:\pythons\python37\lib\site-packages\device_detector\parser\parser.py", line 73, in _parse
    for ua_data in self.regex_list:
  File "c:\pythons\python37\lib\site-packages\device_detector\yaml_loader.py", line 69, in regex_list
    regex['regex'] = re.compile(BOUNDED_REGEX.format(regex['regex']), re.IGNORECASE)
  File "c:\pythons\python37\lib\re.py", line 234, in compile
    return _compile(pattern, flags)
  File "c:\pythons\python37\lib\re.py", line 286, in _compile
    p = sre_compile.compile(pattern, flags)
  File "c:\pythons\python37\lib\sre_compile.py", line 768, in compile
    code = _code(p, flags)
  File "c:\pythons\python37\lib\sre_compile.py", line 607, in _code
    _compile(code, p.data, flags)
  File "c:\pythons\python37\lib\sre_compile.py", line 168, in _compile
    _compile(code, p, _combine_flags(flags, add_flags, del_flags))
  File "c:\pythons\python37\lib\sre_compile.py", line 209, in _compile
    _compile(code, av, flags)
  File "c:\pythons\python37\lib\sre_compile.py", line 182, in _compile
    raise error("look-behind requires fixed-width pattern")
re.error: look-behind requires fixed-width pattern

Directory regexes is missing

The parsing can't work without the regexes folder :(

bots.yml does not exist
oss.yml does not exist
client/feed_readers.yml does not exist
client/mobile_apps.yml does not exist
client/mediaplayers.yml does not exist
client/pim.yml does not exist
client/browsers.yml does not exist
client/libraries.yml does not exist
device/consoles.yml does not exist
device/car_browsers.yml does not exist
device/cameras.yml does not exist
device/portable_media_player.yml does not exist
device/mobiles.yml does not exist
vendorfragments.yml does not exist

Adding new yml file

First of all! This is a great library.
I would like to know how can we deal with adding new yml file for extracting custom components?

Getting `look-behind requires fixed-width pattern` error

I'm getting look-behind requires fixed-width pattern error when literally trying to run the example in the README.

My current Python version is 3.6.8 and my code looks something like this:

from device_detector import DeviceDetector

ua = 'Mozilla/5.0 (Linux; Android 4.3; C5502 Build/10.4.1.B.0.101) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.136 Mobile Safari/537.36'

device = DeviceDetector(ua).parse()

So, exactly like in the example. The only thing I can think of is the Python version, any idea why this could be colliding somehow?

I can provide a full stacktrace, but the relevant places seem to be:

.venv/lib/python3.6/site-packages/device_detector/parser/parser.py in _parse
73. for ua_data in self.regex_list:

.venv/lib/python3.6/site-packages/device_detector/yaml_loader.py in regex_list
69. regex['regex'] = re.compile(BOUNDED_REGEX.format(regex['regex']), re.IGNORECASE)

I will update my virtualenv with a new python version, just to see what happens. I'll keep you posted

The Package identifing galaxy gear as smartphone

hey, the useragent "Mozilla/5.0 (Linux; Tizen 2.4; SAMSUNG SM-R760) AppleWebKit/537.3 (KHTML, like Gecko) SamsungBrowser/1.1 Mobile Safari/537.3'" parsing as smartphone and not as watch.

other than that, great Package. thanks!!!

Regex trace - look-behind requires fixed-width pattern

Trying to use device-detector
from device_detector import DeviceDetector
ua = 'Mozilla/5.0 (Linux; Android 4.3; C5502 Build/10.4.1.B.0.101) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.136 Mobile Safari/537.36'
DeviceDetector(ua).parse() results in trace

Here is the stacktrace
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/device_detector/device_detector.py", line 213, in parse
self.parse_bot()
File "/usr/local/lib/python3.6/site-packages/device_detector/device_detector.py", line 272, in parse_bot
self.bot = Bot(self.user_agent).parse()
File "/usr/local/lib/python3.6/site-packages/device_detector/parser/parser.py", line 89, in parse
self._parse()
File "/usr/local/lib/python3.6/site-packages/device_detector/parser/parser.py", line 73, in _parse
for ua_data in self.regex_list:
File "/usr/local/lib/python3.6/site-packages/device_detector/yaml_loader.py", line 69, in regex_list
regex['regex'] = re.compile(BOUNDED_REGEX.format(regex['regex']), re.IGNORECASE)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 566, in compile
code = _code(p, flags)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 551, in _code
_compile(code, p.data, flags)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 146, in _compile
_compile(code, p, (flags | add_flags) & ~del_flags)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 146, in _compile
_compile(code, p, (flags | add_flags) & ~del_flags)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 187, in _compile
_compile(code, av, flags)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 160, in _compile
raise error("look-behind requires fixed-width pattern")
sre_constants.error: look-behind requires fixed-width pattern

Issue with the library?

Regex issue while importing device_detector

When I try to import device_detector, I got the following error though I have installed regex.

Traceback (most recent call last): File "/home/ayesh/PycharmProjects/LogParcer/venv/preProcessor.py", line 4, in <module> import device_detector File "/home/ayesh/PycharmProjects/LogParcer/venv/lib/python3.6/site-packages/device_detector/__init__.py", line 3, in <module> from .parser import * File "/home/ayesh/PycharmProjects/LogParcer/venv/lib/python3.6/site-packages/device_detector/parser/__init__.py", line 1, in <module> from .client import * File "/home/ayesh/PycharmProjects/LogParcer/venv/lib/python3.6/site-packages/device_detector/parser/client/__init__.py", line 1, in <module> from .base import * File "/home/ayesh/PycharmProjects/LogParcer/venv/lib/python3.6/site-packages/device_detector/parser/client/base.py", line 7, in <module> from ..parser import Parser File "/home/ayesh/PycharmProjects/LogParcer/venv/lib/python3.6/site-packages/device_detector/parser/parser.py", line 9, in <module> from .extractors import ( File "/home/ayesh/PycharmProjects/LogParcer/venv/lib/python3.6/site-packages/device_detector/parser/extractors.py", line 9, in <module> APP_ID = re.compile(r'\b([a-z]{2,5}\.[\w\d\.\-]+)', re.IGNORECASE) AttributeError: module 'regex' has no attribute 'compile'

Regularly outputs "xxx does not exist" errors (0.8 from pip)

Hi, I'm seeing things like the following being printed out all the time:

device_detector/appids/secondary.yml does not exist
device_detector/appdetails/games.yml does not exist
device_detector/appdetails/messaging.yml does not exist
device_detector/appdetails/mobile_apps.yml does not exist
device_detector/appdetails/mediaplayers.yml does not exist
device_detector/appdetails/p2p.yml does not exist
device_detector/appdetails/pim.yml does not exist
device_detector/appdetails/vpnproxy.yml does not exist
device_detector/appdetails/osutility.yml does not exist
device_detector/appdetails/antivirus.yml does not exist
device_detector/appdetails/desktop_apps.yml does not exist
device_detector/appids/secondary.yml does not exist
device_detector/appids/ignored.yml does not exist
device_detector/appids/normalized.yml does not exist

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.