Example #1
0
File: meta.py Project: vasc/couchee
def download_posters():
    db = pymongo.Connection().usenet
    dbmovies = pymongo.Connection().imdb
    folder = db.config.find_one({'type': 'folder', 'category': 'meta'})['folders']['movies']

    tmdb = TMDB('f765d363ee59032855f018253ae2a266', 'json', 'en')
    for nzb in db.nzbs.find({'stages.movieid': True, 'stages.poster': {'$ne': True}}):
        m = dbmovies.movies.find_one({'_id': nzb['movieid']})
        if m and 'poster' in m['stages']:
            nzb['stages']['poster'] = True
            db.nzbs.save(nzb)
            continue

        if not m: m = {'_id': nzb['movieid'], 'stages': [], 'posters': []}
        if not 'posters' in m: m['posters'] = []

        imdb_info = tmdb.imdbResults(nzb['movieid'])
        obj = json.loads(imdb_info)[0]
        count = 1

        if 'posters' in obj:
            for p in obj['posters']:
                p = p['image']
                if p['type'] == 'poster' and p['size'] == 'original':
                    v = 'y'
                    print v, nzb['rlsname'], p['url']
                    f = nzb['movieid']+'.'+str(count)+'.jpg'
                    if download_poster(p['url'], os.path.join(folder, f)):
                        m['posters'].append(f)
                        count += 1
                        logging.info("Poster %s %s" % (nzb['rlsname'], f))
                        print "Poster %s %s" % (nzb['rlsname'], f)
                    else: "Error downloading %s" % p['url']

        dbmovies.movies.save(m)
        nzb['stages']['poster'] = True
        db.nzbs.save(nzb)
Example #2
0
import pymongo
from themoviedb.tmdb import TMDB
import json
import pprint
import urllib

db = pymongo.Connection().usenet
#for movie in db.movies.find({"votes": {'$lt': 5000}}).sort('votes', pymongo.DESCENDING).limit(100).skip(0):
for movie in db.nzbs.find({"stages.movieid": True}):#.sort('votes', pymongo.DESCENDING).limit(100).skip(0):
    tmdb = TMDB('f765d363ee59032855f018253ae2a266', 'json', 'en')
    imdb_info = tmdb.imdbResults(movie['movieid'])
    obj = json.loads(imdb_info)[0]
    
    v = 'n'
    url = ''
    count = 1
    
    if 'posters' in obj:
          for p in obj['posters']:
              p = p['image']
              if p['type'] == 'poster' and p['size'] == 'cover':
                  v = 'y',
                  url = p['url']
                  urllib.urlretrieve(url, 'poster/'+movie['movieid']+'.'+str(count)+'.jpg')
                  count += 1
                  print v, movie['rlsname'], url