Movie add
JSONP
This commit is contained in:
1 parent
f9523444f4
commit
e39de40d2d
24 files changed
+871
-5029
No files matched your search
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from couchpotato.core.logger import CPLog
|
||||
from string import ascii_letters, digits
|
||||
import re
|
||||
import unicodedata
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
def toSafeString(original):
|
||||
valid_chars = "-_.() %s%s" % (ascii_letters, digits)
|
||||
cleanedFilename = unicodedata.normalize('NFKD', toUnicode(original)).encode('ASCII', 'ignore')
|
||||
return ''.join(c for c in cleanedFilename if c in valid_chars)
|
||||
|
||||
def simplifyString(original):
|
||||
string = toSafeString(original)
|
||||
split = re.split('\W+', string.lower())
|
||||
return toUnicode(' '.join(split))
|
||||
|
||||
def toUnicode(original, *args):
|
||||
try:
|
||||
if type(original) is unicode:
|
||||
return original
|
||||
else:
|
||||
return unicode(original, *args)
|
||||
except UnicodeDecodeError:
|
||||
ascii_text = str(original).encode('string_escape')
|
||||
return unicode(ascii_text)
|
||||
@@ -0,0 +1,22 @@
|
||||
from flask.globals import current_app
|
||||
from flask.helpers import json, jsonify
|
||||
import flask
|
||||
|
||||
|
||||
def getParams():
|
||||
return getattr(flask.request, 'args')
|
||||
|
||||
def getParam(attr, default = None):
|
||||
return getattr(flask.request, 'args').get(attr, default)
|
||||
|
||||
def padded_jsonify(callback, *args, **kwargs):
|
||||
content = str(callback) + '(' + json.dumps(dict(*args, **kwargs)) + ')'
|
||||
return current_app.response_class(content, mimetype = 'text/javascript')
|
||||
|
||||
def jsonified(*args, **kwargs):
|
||||
from couchpotato.environment import Env
|
||||
callback = getParam('json_callback', None)
|
||||
if callback:
|
||||
return padded_jsonify(callback, *args, **kwargs)
|
||||
else:
|
||||
return jsonify(*args, **kwargs)
|
||||
@@ -0,0 +1,33 @@
|
||||
from couchpotato.core.logger import CPLog
|
||||
import xml.etree.ElementTree as XMLTree
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
class RSS():
|
||||
|
||||
def gettextelements(self, xml, path):
|
||||
''' Find elements and return tree'''
|
||||
|
||||
textelements = []
|
||||
try:
|
||||
elements = xml.findall(path)
|
||||
except:
|
||||
return
|
||||
for element in elements:
|
||||
textelements.append(element.text)
|
||||
return textelements
|
||||
|
||||
def gettextelement(self, xml, path):
|
||||
''' Find element and return text'''
|
||||
|
||||
try:
|
||||
return xml.find(path).text
|
||||
except:
|
||||
return
|
||||
|
||||
def getItems(self, data, path = 'channel/item'):
|
||||
try:
|
||||
return XMLTree.parse(data).findall(path)
|
||||
except Exception, e:
|
||||
log.error('Error parsing RSS. %s' % e)
|
||||
return []
|
||||
Reference in new issue
Block a user