X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/13480b3da2d3da87f1d99c6d340c1553ca9d89c1..refs/heads/xml2:/librarian/__init__.py diff --git a/librarian/__init__.py b/librarian/__init__.py index 0616f23..ec1d688 100644 --- a/librarian/__init__.py +++ b/librarian/__init__.py @@ -3,12 +3,27 @@ # This file is part of Librarian, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -import os import re import urllib from .utils import XMLNamespace +VIDEO_PROVIDERS = { + 'youtube': { + 'url': 'https://www.youtube.com/watch?v=%s', + 'embed': '//www.youtube.com/embed/%s?controls=2&rel=0&showinfo=0&theme=light', + }, + 'vimeo': { + 'url': 'https://vimeo.com/%s', + 'embed': '//player.vimeo.com/video/%s', + }, +} + + +def get_provider(provider_id): + return VIDEO_PROVIDERS.get(provider_id, VIDEO_PROVIDERS['youtube']) + + class UnicodeException(Exception): def __str__(self): """ Dirty workaround for Python Unicode handling problems. """ @@ -23,13 +38,24 @@ class UnicodeException(Exception): message = unicode(args, encoding='utf-8', errors='ignore') return message + class ParseError(UnicodeException): pass + class ValidationError(UnicodeException): pass +# was deleted, but still used??? +class NoDublinCore(ValidationError): + pass + + +class BuildError(Exception): + pass + + class EmptyNamespace(XMLNamespace): def __init__(self): super(EmptyNamespace, self).__init__('') @@ -53,8 +79,7 @@ class WLURI(object): slug = None example = 'http://wolnelektury.pl/katalog/lektura/template/' - _re_wl_uri = re.compile(r'http://(www\.)?wolnelektury.pl/katalog/lektura/' - '(?P[-a-z0-9]+)/?$') + _re_wl_uri = re.compile(r'http://(www\.)?wolnelektury.pl/katalog/lektura/(?P[-a-z0-9]+)/?$') def __init__(self, uri): uri = unicode(uri) @@ -93,4 +118,3 @@ class WLURI(object): class URLOpener(urllib.FancyURLopener): version = 'FNP Librarian (http://git.nowoczesnapolska.org.pl/?p=librarian.git)' urllib._urlopener = URLOpener() -