Example #1
0
    def onLoad(self):
        self.handledExternally = {}
        """@type : dict[str, list[str]]"""
        # dict of regex patterns not to follow. populated by other modules so they can handle them themselves

        self.youtubeKey = load_key(u'YouTube')
        self.imgurClientID = load_key(u'imgur Client ID')
Example #2
0
    def onLoad(self):
        self.handledExternally = {}
        """@type : dict[str, list[str]]"""
        # dict of regex patterns not to follow. populated by other modules so they can handle them themselves

        self.youtubeKey = load_key(u'YouTube')
        self.imgurClientID = load_key(u'imgur Client ID')
        
        self.autoFollow = True
Example #3
0
def googleSearch(query):
    """
    @type query: unicode
    @rtype: dict[unicode, T]
    """
    googleKey = load_key(u'Google')

    service = build('customsearch', 'v1', developerKey=googleKey)
    res = service.cse().list(q=query,
                             cx='002603151577378558984:xiv3qbttad0').execute()
    return res
Example #4
0
    def _get_access_token(self):
        """Obtain a bearer token."""
        consumer_key = api_keys.load_key("Twitter Key")
        consumer_secret = api_keys.load_key("Twitter Secret")

        if consumer_key is None or consumer_secret is None:
            raise TwitterAPIKeysMissing('Twitter API Keys are missing, cannot use Twitter API')

        bearer_token = '%s:%s' % (consumer_key, consumer_secret)
        encoded_bearer_token = base64.b64encode(bearer_token.encode('ascii'))
        request = Request('https://api.twitter.com/oauth2/token')
        request.add_header('Content-Type',
                           'application/x-www-form-urlencoded;charset=UTF-8')
        request.add_header('Authorization',
                           'Basic %s' % encoded_bearer_token.decode('utf-8'))
        request.add_data('grant_type=client_credentials'.encode('ascii'))

        response = urlopen(request)
        raw_data = response.read().decode('utf-8')
        data = json.loads(raw_data)
        return data['access_token']
Example #5
0
def googleSearch(query):
    """
    @type query: unicode
    @rtype: dict[unicode, T]
    """
    googleKey = load_key(u'Google')
    
    service = build('customsearch', 'v1', developerKey=googleKey)
    res = service.cse().list(
        q = query,
        cx = '002603151577378558984:xiv3qbttad0'
    ).execute()
    return res
Example #6
0
    def _get_access_token(self):
        """Obtain a bearer token."""
        consumer_key = api_keys.load_key("Twitter Key")
        consumer_secret = api_keys.load_key("Twitter Secret")

        if consumer_key is None or consumer_secret is None:
            raise TwitterAPIKeysMissing(
                'Twitter API Keys are missing, cannot use Twitter API')

        bearer_token = '%s:%s' % (consumer_key, consumer_secret)
        encoded_bearer_token = base64.b64encode(bearer_token.encode('ascii'))
        request = Request('https://api.twitter.com/oauth2/token')
        request.add_header('Content-Type',
                           'application/x-www-form-urlencoded;charset=UTF-8')
        request.add_header('Authorization',
                           'Basic %s' % encoded_bearer_token.decode('utf-8'))
        request.add_data('grant_type=client_credentials'.encode('ascii'))

        response = urlopen(request)
        raw_data = response.read().decode('utf-8')
        data = json.loads(raw_data)
        return data['access_token']
Example #7
0
def shortenGoogl(url):
    """
    @type url: unicode
    @rtype: unicode
    """
    post = '{{"longUrl": "{}"}}'.format(url)

    googlKey = load_key(u'goo.gl')

    if googlKey is None:
        return "[goo.gl API key not found]"

    apiURL = 'https://www.googleapis.com/urlshortener/v1/url?key={}'.format(googlKey)

    headers = {"Content-Type": "application/json"}

    try:
        request = Request(apiURL, post, headers)
        response = json.loads(urlopen(request).read())
        return response['id']

    except Exception, e:
        print "Goo.gl error: %s" % e
Example #8
0
def shortenGoogl(url):
    """
    @type url: unicode
    @rtype: unicode
    """
    post = '{{"longUrl": "{}"}}'.format(url)

    googlKey = load_key(u'goo.gl')

    if googlKey is None:
        return "[goo.gl API key not found]"

    apiURL = 'https://www.googleapis.com/urlshortener/v1/url?key={}'.format(
        googlKey)

    headers = {"Content-Type": "application/json"}

    try:
        request = Request(apiURL, post, headers)
        response = json.loads(urlopen(request).read())
        return response['id']

    except Exception, e:
        print "Goo.gl error: %s" % e
Example #9
0
 def onLoad(self):
     self.imgurClientID = load_key(u"imgur Client ID")
     self.headers = [("Authorization", "Client-ID {}".format(self.imgurClientID))]
Example #10
0
 def onLoad(self):
     self.api_key = load_key(u'Bing Maps')
Example #11
0
 def onLoad(self):
     self.imgurClientID = load_key(u'imgur Client ID')
     self.headers = [('Authorization', 'Client-ID {}'.format(self.imgurClientID))]
Example #12
0
 def onLoad(self):
     self.youtubeKey = load_key(u'YouTube')
     self.imgurClientID = load_key(u'imgur Client ID')
Example #13
0
 def onLoad(self):
     self.api_key = load_key(u'Bing Maps')
Example #14
0
 def onLoad(self):
     self.imgurClientID = load_key(u'imgur Client ID')
     self.headers = [('Authorization', 'Client-ID {}'.format(self.imgurClientID))]