2017-12-23 23:29:16 +00:00
|
|
|
import re
|
|
|
|
from urlparse import urlparse
|
|
|
|
|
|
|
|
from regluit.utils.lang import get_language_code
|
|
|
|
from . import BaseScraper
|
|
|
|
|
|
|
|
|
|
|
|
HAS_EDS = re.compile(r'\(eds?\.\)')
|
|
|
|
UBIQUITY_HOSTS = ["ubiquitypress.com", "kriterium.se", "oa.finlit.fi", "humanities-map.net",
|
|
|
|
"oa.psupress.org", "larcommons.net", "uwestminsterpress.co.uk", "stockholmuniversitypress.se",
|
|
|
|
"luminosoa.org",
|
|
|
|
]
|
|
|
|
|
|
|
|
class UbiquityScraper(BaseScraper):
|
|
|
|
can_scrape_hosts = UBIQUITY_HOSTS
|
|
|
|
def get_role(self):
|
|
|
|
descs = self.doc.select('section.book-description')
|
|
|
|
for desc in descs:
|
|
|
|
if desc.find(string=HAS_EDS):
|
|
|
|
return 'editor'
|
2018-02-20 18:07:44 +00:00
|
|
|
return super(UbiquityScraper, self).get_role()
|
2017-12-23 23:29:16 +00:00
|
|
|
|
|
|
|
def get_language(self):
|
|
|
|
langlabel = self.doc.find(string='Language')
|
2018-01-02 00:25:00 +00:00
|
|
|
lang = langlabel.parent.parent.find_next_sibling() if langlabel else ''
|
2017-12-23 23:29:16 +00:00
|
|
|
lang = lang.get_text() if lang else ''
|
|
|
|
lang = get_language_code(lang) if lang else ''
|
|
|
|
if lang:
|
|
|
|
self.set('language', lang)
|
|
|
|
else:
|
2018-02-20 18:07:44 +00:00
|
|
|
super(UbiquityScraper, self).get_language()
|