Beispiel #1
0
try:
    from libs import bottlenose
    import logs

    from libs.LibUtils        import xmlToPython
    from libs.LRUCache        import lru_cache
    from libs.CachedFunction  import cachedFn
    from libs.CountedFunction import countedFn
    from APIKeys              import get_api_key
except:
    report()
    raise

__all__         = [ "Amazon" ]
ASSOCIATE_ID        = get_api_key('amazon', 'associate_id')
AWS_ACCESS_KEY_ID   = get_api_key('amazon', 'aws_access_key_id')
AWS_SECRET_KEY      = get_api_key('amazon', 'aws_secret_key')

class Amazon(object):
    """
        Amazon API wrapper (2)
    """

    def __init__(self):
        self.amazon = bottlenose.Amazon(AWS_ACCESS_KEY_ID, AWS_SECRET_KEY, ASSOCIATE_ID)

    # note: these decorators add tiered caching to this function, such that
    # results will be cached locally with a very small LRU cache of 64 items
    # and also cached in Mongo or Memcached with the standard TTL of 7 days.
    @countedFn(name='Amazon (before caching)')
Beispiel #2
0
from errors import *

from datetime               import datetime, timedelta
from libs.LRUCache          import lru_cache
from libs.CachedFunction    import cachedFn
from libs.CountedFunction   import countedFn
from libs.Request           import *
from APIKeys                import get_api_key

HOST              = 'api-public.netflix.com'
PORT              = '80'
REQUEST_TOKEN_URL = 'http://api-public.netflix.com/oauth/request_token'
ACCESS_TOKEN_URL  = 'http://api-public.netflix.com/oauth/access_token'
AUTHORIZATION_URL = 'https://api-public-user.netflix.com/oauth/login'

APP_NAME                = get_api_key('netflix', 'app_name')
API_KEY                 = get_api_key('netflix', 'api_key')
API_SECRET              = get_api_key('netflix', 'api_secret')

"""
HOST              = 'api.netflix.com'
PORT              = '80'
REQUEST_TOKEN_URL = 'http://api.netflix.com/oauth/request_token'
ACCESS_TOKEN_URL  = 'http://api.netflix.com/oauth/access_token'
AUTHORIZATION_URL = 'https://api-user.netflix.com/oauth/login'
"""

class Netflix(object):
    def __init__(self, name=APP_NAME, key=API_KEY, secret=API_SECRET):
        self.__name=name
        self.__key=key
Beispiel #3
0
import Globals
import json, httplib2
import logs
from errors import *
import oauth as oauth

from libs.Request       import service_request
from APIKeys            import get_api_key

TWITTER_CONSUMER_KEY    = get_api_key('twitter', 'consumer_key')
TWITTER_CONSUMER_SECRET = get_api_key('twitter', 'consumer_secret')

class Twitter(object):
    def __init__(self, consumer_key=TWITTER_CONSUMER_KEY, consumer_secret=TWITTER_CONSUMER_SECRET):
        self.__consumer_key         = consumer_key
        self.__consumer_secret      = consumer_secret
        self.__consumer             = oauth.OAuthConsumer(self.__consumer_key, self.__consumer_secret)
        self.__signature_method     = oauth.OAuthSignatureMethod_HMAC_SHA1()
        self.__httpObj              = httplib2.Http()

    def __http(self, verb, service, user_token=None, user_secret=None, priority='high', **params):

        url = 'https://api.twitter.com/%s' % service

        # Generate the oauth token from the user_token and user_secret
        if user_token is not None and user_secret is not None:
            token = oauth.OAuthToken(
                user_token,
                user_secret,
            )
Beispiel #4
0
import Globals
import string, sys, urllib, utils

from api.Schemas import *
from optparse import OptionParser
from libs.LibUtils import parseDateString
from lxml import objectify, etree
from pprint import pprint
from libs.LRUCache import lru_cache
from libs.CachedFunction import cachedFn
from libs.CountedFunction import countedFn
from libs.Request import service_request
from api.Schemas import MediaCollectionEntity
from APIKeys import get_api_key

API_KEY = get_api_key("tvdb", "api_key")


class TheTVDB(object):
    def __init__(self, api_key=API_KEY):
        self.api_key = api_key

    # note: these decorators add tiered caching to this function, such that
    # results will be cached locally with a very small LRU cache of 64 items
    # and also cached in Mongo or Memcached with the standard TTL of 7 days.
    @countedFn(name="TheTVDB (before caching)")
    @lru_cache(maxsize=64)
    @cachedFn(schemaClasses=[MediaCollectionEntity])
    @countedFn(name="TheTVDB (after caching)")
    def searchRaw(self, query, priority="low", timeout=None):
Beispiel #5
0
import json, urllib
import datetime, logs, sys, time

from pprint import pprint
from libs.LRUCache import lru_cache
from libs.Memcache import memcached_function
from api.Schemas import Menu
from api.Schemas import Submenu
from api.Schemas import MenuSection
from api.Schemas import MenuItem
from api.Schemas import MenuPrice
from threading import Lock
from libs.Request import service_request
from APIKeys import get_api_key

CLIENT_ID = get_api_key("singleplatform", "client_id")
SIGNING_KEY = get_api_key("singleplatform", "signing_key")
API_KEY = get_api_key("singleplatform", "api_key")

_spicy_map = {"none": 0, "mild": 1, "medium": 2, "hot": 3}


def _parse_spicy(entry):
    if "spicy" in entry:
        v = entry["spicy"]
        if v in _spicy_map:
            return _spicy_map[v]
    return None


def _parse_prices(entry):
Beispiel #6
0
    from urllib                 import quote_plus
    from django.utils.encoding  import iri_to_uri
    from libs.Request           import service_request
    from APIKeys                import get_api_key
    from errors                 import *

    try:
        import json
    except ImportError:
        import simplejson as json
except:
    report()
    raise


API_KEY         = get_api_key('rdio', 'api_key')
API_SECRET      = get_api_key('rdio', 'api_secret')


def urlencode_utf8(params):
    return urllib.urlencode(params)
    """
    return '&'.join(
        (quote_plus(k, safe='/') + '=' + iri_to_uri(v)
            for k, v in params.items()))
    """

class Rdio(object):

    def __init__(self, key=API_KEY, secret=API_SECRET):
        self.__key      = key
Beispiel #7
0
import Globals
import time
import urllib, json, urlparse
import logs, utils
import re
from errors import *
from libs.Request import service_request
from APIKeys import get_api_key
from datetime import datetime
import httplib2
from BeautifulSoup import BeautifulSoup



APP_ID          = get_api_key('facebook', 'app_id')
APP_SECRET      = get_api_key('facebook', 'app_secret')
APP_NAMESPACE   = get_api_key('facebook', 'app_namespace')

ACCESS_TOKEN = 'AAAEOIZBBUXisBAFC4pEYEpUYJlzM7FPq9m77m7k2k5wIrcZCmXSZC0TT1ri6VcMWV5acLBZAs6lHzdkFJrWHZASY4XbKTqUQZD'
USER_ID = '1337040065'
CODE = 'AQCKon1gU-jv8gYtZnXHYjjK-tG63ZbW9EFo-Vk5AAGgPfYua4Rr_g_Z2BTqUOMeqpt1wja1pCJL-dg5Fogo6VIWcJeHiBoNVqUSsHMok-fjXXogJ2qyANmw8xqWw51qz5XJdPHqCAgRCXYgRA5HC8vnQHw8AojNyudbKKdGOxCuudgXDbpAv2E0Nl9jlzpc2RnH1M_Ixcdy622-QNUYX2Sw'

DEFAULT_TIMEOUT = 15

class Facebook(object):
    def __init__(self, app_id=APP_ID, app_secret=APP_SECRET, app_namespace=APP_NAMESPACE):
        self.app_id         = app_id
        self.app_secret     = app_secret
        self.app_namespace  = app_namespace
        pass
Beispiel #8
0
from libs.CountedFunction   import countedFn
from api.Schemas            import BasicEntity
from libs.SinglePlatform    import StampedSinglePlatform
from pprint                 import pprint
from functools              import partial
from urllib2                import HTTPError
from gevent                 import sleep
from re                     import match
from datetime               import datetime
from datetime               import timedelta
from utils                  import lazyProperty
from libs.RateLimiter       import RateLimiter
from libs.Request           import service_request
from APIKeys                import get_api_key

_API_V3_Key             = get_api_key('factual', 'api_key')
_API_V3_Secret          = get_api_key('factual', 'api_secret')
_limit = 20


def _path(path_string, entity, subfunc=None):
    """
    Helper function for creating resolve filters

    See _relevant_fields for usage.
    _path assumes that is working with dictionary like elements
    except for leafs and wildcard iterables
    """
    path = path_string.split()
    cur = entity.dataExport()
    for k in path: