# 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. """
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__('')
slug = None
example = 'http://wolnelektury.pl/katalog/lektura/template/'
- _re_wl_uri = re.compile(r'http://(www\.)?wolnelektury.pl/katalog/lektura/'
- '(?P<slug>[-a-z0-9]+)/?$')
+ _re_wl_uri = re.compile(r'http://(www\.)?wolnelektury.pl/katalog/lektura/(?P<slug>[-a-z0-9]+)/?$')
def __init__(self, uri):
uri = unicode(uri)
class URLOpener(urllib.FancyURLopener):
version = 'FNP Librarian (http://git.nowoczesnapolska.org.pl/?p=librarian.git)'
urllib._urlopener = URLOpener()
-