python-user-agents icon indicating copy to clipboard operation
python-user-agents copied to clipboard

Firefox OS issues

Open miketaylr opened this issue 11 years ago • 6 comments

Hi there. There's currently some problems with parsing Firefox OS ua strings:

Firefox OS Mobile:

>>> ua_string = 'Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0'
>>> b = parse(ua_string)
>>> b.device
Device(family='Other')
>>> b.browser
Browser(family=u'Firefox Mobile', version=(26,), version_string='26')
>>> b.is_tablet
False
>>> b.is_mobile
False
>>> b.is_touch_capable
False
>>> b.os
OperatingSystem(family=u'Firefox OS', version=(), version_string='')

is_mobile and is_touch_capable should be true.

Firefox OS for tablets:

>>> ua_string = 'Mozilla/5.0 (Tablet; rv:29.0) Gecko/29.0 Firefox/29.0'
>>> b = parse(ua_string)
>>> b.is_mobile
False
>>> b.is_touch_capable
False
>>> b.is_tablet
False
>>> b.os
OperatingSystem(family='Other', version=(), version_string='')
>>> b.device
Device(family='Other')

is_mobile and is_touch_capable should be true. os.family should report Firefox OS -- I've made a pull request against ua-parser for that though: https://github.com/tobie/ua-parser/pull/331

miketaylr avatar Jan 23 '14 22:01 miketaylr

I'm happy to provide a patch. Not today. but next week.

karlcow avatar Jan 24 '14 02:01 karlcow

@karlcow thanks for the offer :). Let's hope that https://github.com/tobie/ua-parser/pull/331 gets merged soon.

selwin avatar Jan 24 '14 08:01 selwin

Oh. Indeed you have a dependency on @tobie library. Understood aand @miketaylr already did a patch there.

from ua_parser import user_agent_parser

karlcow avatar Jan 27 '14 03:01 karlcow

This can be closed as FIXED.

>>> # Accessing user agent's browser attributes
... user_agent.browser  
Browser(family='Firefox Mobile', version=(44,), version_string='44')
>>> user_agent.browser.family  
'Firefox Mobile'
>>> user_agent.browser.version 
(44,)
>>> user_agent.browser.version_string
'44'
>>> 
>>> # Accessing user agent's operating system properties
... user_agent.os  
OperatingSystem(family='Firefox OS', version=(), version_string='')
>>> user_agent.os.family  
'Firefox OS'
>>> user_agent.os.version 
()
>>> user_agent.os.version_string
''
>>> 
>>> # Accessing user agent's device properties
... user_agent.device  
Device(family='Generic Smartphone', brand='Generic', model='Smartphone')
>>> user_agent.device.family 
'Generic Smartphone'
>>> user_agent.device.brand 
'Generic'
>>> user_agent.device.model
'Smartphone'
>>> 
>>> # Viewing a pretty string version
... str(user_agent)
'Generic Smartphone / Firefox OS / Firefox Mobile 44'
>>> user_agent.is_touch_capable
False
>>> user_agent.is_tablet
False
>>> user_agent.is_mobile
True
>>> 

maybe apart the is_touch_capable

karlcow avatar Feb 03 '16 01:02 karlcow

Not sure why btw https://github.com/selwin/python-user-agents/blob/master/user_agents/parsers.py#L58-L66

karlcow avatar Feb 03 '16 02:02 karlcow

Just an old version.

>>> import user_agents
>>> user_agents.VERSION
(0, 3, 2)

Let's close it as Fixed.

karlcow avatar Feb 03 '16 02:02 karlcow