Пример #1
0
 def collectVideoData(self, page=0, count=1):
     #https://api.flattr.com/rest/v2/things/search?url="vimeo.com"|"youtube.com"
     end = urlquote('"vimeo.com"|"youtube.com"')
     url = 'https://api.flattr.com/rest/v2/things/search?sort=trend&url='+end+'&count=' + str(count)
     print url
     if page != 0:
         url += "&page=" + urlquote(page)
     r = requests.get(url)
     if r.status_code != 200:
         print "Problem contacting flattr!"
         return ""
     return json.loads(r.content)
Пример #2
0
 def getVideoById(self, id, big=False):
     url = "https://api.flattr.com/rest/v2/things/" + urlquote(id)
     r = requests.get(url)
     if r.status_code != 200:
         print "Problem contacting flattr!"
         return None
     video = json.loads(r.content)
     return Video(video[u'title'], video[u'id'], video[u'url'], big)
Пример #3
0
 def getOembed(self, url, big=False):
     if not big:
         size = "&maxwidth=600&maxheight=360"
     else:
         size ="&maxwidth=1200"
     oembedJunctionURL = "http://oembed-junction.herokuapp.com/?format=json"+size+"&url="
     r = requests.get(oembedJunctionURL + quote(url, ''))
     print oembedJunctionURL + urlquote(url)
     if r.status_code in [404,500]:
         return False
     content = json.loads(r.content)
     return content
Пример #4
0
 def getRandomVideo(self, big=False):
     while True:
         rand = randint(0,140)
         end = urlquote('"vimeo.com"|"youtube.com"')
         url = 'https://api.flattr.com/rest/v2/things/search?sort=trend&url='+end+'&count=1&page=' + str(rand)
         #url = 'https://api.flattr.com/rest/v2/things/search?query="vimeo.com"&count=1&page=' + str(rand)
         print url
         r = requests.get(url)
         if r.status_code != 200:
             print "Problem contacting flattr!"
             return None
         videolist = json.loads(r.content)
         for video in videolist[u'things']:
             result = Video(video[u'title'], video[u'id'], video[u'url'], big)
             if result.embeddedcode != "":
                 return result