Demo entry 6327747

test

   

Submitted by anonymous on Nov 24, 2016 at 16:40
Language: Python. Code size: 2.0 kB.

import httplib as http
import requests
import json
import urllib
import dataset
from audiosearch import Client
#usando a api deste diretorio https://www.audiosear.ch/developer

#connect to db stuff
#db = dataset.connect('mysql://root:546879@localhost:3306/newBdPodcasts')
 
#db = dataset.connect('mysql://userTest:test123@localhost:3306/newPodcasts')
db = dataset.connect('mysql://dbProject:nicepass@project.hlopes.me:3306/dbProject')
tableSeries = db['Series']

#authentication stuff for the API
client = Client('3d15156fa8888c059d3a8d542a3fc4a1c838948c8f21ce2344c465d90d712790', 'edf494940bd83d8e6f1d018254d13ccdb30e18a6627682d5c97e6419edac1c2e')

#res = client.search({ 'q':'*', 'size':'200', 'from':'0', 'page':'2'}, 'shows')
#res = client.get('/search/shows', params)
#print(res)
#for shows in res['results']:
#  print "[%s] %s (%s)" % ( shows['id'], shows['title'], shows['network'] )

idShow = 14999
while (idShow< 3000):
    res = client.get_show(str(idShow))
    if('status' in res):
        idShow = idShow + 1
    else:
        #print(res)
        print "[%s] %s" % ( res['id'], res['title'])
        if res["image_files"] :
            imgdict = (res["image_files"][ 0])
            imgdict = imgdict['url']
            tableSeries.upsert(dict(seriesId= idShow, imageUrl = imgdict['full'].encode(encoding='utf-8')), ['seriesId'])
        if res["title"] :
            tableSeries.upsert(dict(seriesId= idShow, title = res["title"].encode(encoding='utf-8')), ['seriesId'])
        #if imgdict['full'] :
        #    tableSeries.upsert(dict(seriesId= idShow, imageUrl = imgdict['full'].encode(encoding='utf-8')), ['seriesId'])
        if hasattr(res, "rss_url") and res["rss_url"] :
            print(res["rss_url"] )
            tableSeries.upsert(dict(seriesId= idShow, feedUrl = res["rss_url"].encode(encoding='utf-8')), ['seriesId'])
        if res["description"] :
            tableSeries.upsert(dict(seriesId= idShow, description = res["description"].encode(encoding='utf-8')), ['seriesId'])
        idShow = idShow + 1
    

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).