Beispiel #1
0
def searchmovie(id, an=None, cache=True):
    basic.log(u"omdbapi.searchmovie id: %s" % id)
    listgenre = []
    listcast = []
    listcastr = []
    genre = ''
    title = ''
    plot = ''
    tagline = ''
    director = ''
    writer = ''
    credits = ''
    poster = ''
    fanart = ''
    trailer = ''
    year = ''
    dur = 0
    if cache:
        if getSetting("cachesites") == 'true':
            cached = localdb.get_cache(id, an)
            if cached:
                response = {
                    "label": cached[2],
                    "originallabel": cached[3],
                    "poster": cached[4],
                    "fanart_image": cached[5],
                    "imdbid": cached[0],
                    "year": cached[6],
                    "info": json.loads(cached[7])
                }
                return response
    if an:
        ordine = id[0]
        imagine = id[1]
        nume = id[2]
        an = id[3]
        regia = id[4]
        actori = id[5]
        gen = id[6]
        nota = id[7]
        trailer = id[8]
        descriere = id[9]
        id = '1'
        #jsonpage = basic.open_url(links.link().omdbapi_byname % (nume.encode('ascii','xmlcharrefreplace'), an))
        jsonpage = {}
    else:
        jsonpage = basic.open_url(links.link().omdbapi_info % (id))
    try:
        jdef = json.loads(jsonpage)
    except:
        try:
            nume = nume.decode('utf-8')
        except:
            nume = nume
        jdef = {
            'Title': nume,
            'Poster': imagine,
            'Genre': striphtml(gen),
            'Plot': descriere,
            'Year': an,
            'Actors': re.sub('Cu: ', '', striphtml(actori)),
            'Director': re.sub('Regia: ', '', striphtml(regia)),
            'Writer': '',
            'Runtime': '',
            'imdbRating': re.sub('IMDB: ', '', nota),
            'imdbVotes': '',
            'trailer': trailer
        }
    try:
        title = jdef['Title']
    except:
        title = nume
    try:
        poster = jdef['Poster']
    except:
        poster = imagine
    fanart = poster
    try:
        genre = jdef['Genre']
    except:
        genre = striphtml(gen)
    try:
        plot = jdef['Plot']
    except:
        plot = descriere
    tagline = plot
    try:
        year = re.findall('(\d+)', jdef['Year'], re.DOTALL)[0]
    except:
        try:
            year = jdef['Year']
        except:
            year = an
    try:
        listcast = jdef['Actors'].split(', ')
    except:
        listcast = re.sub('Cu: ', '', striphtml(actori)).split(', ')
    try:
        director = jdef['Director']
    except:
        director = re.sub('Regia: ', '', striphtml(regia))
    try:
        writer = jdef['Writer']
    except:
        writer = ''
    try:
        duration = re.findall('(\d+) min', jdef['Runtime'], re.DOTALL)
        if duration: dur = int(duration[0])
        else:
            duration = re.findall('(\d) h', jdef['Runtime'], re.DOTALL)
            if duration: dur = int(duration[0]) * 60
    except:
        duration = ''
    try:
        rating = jdef['imdbRating']
    except:
        rating = re.sub('IMDB: ', '', nota)
    try:
        votes = jdef['imdbVotes']
    except:
        votes = ''
    try:
        trailer = jdef['trailer']
    except:
        trailer = ''
    info = {
        "genre": genre,
        "year": year,
        "rating": rating,
        "cast": listcast,
        "castandrole": listcast,
        "director": director,
        "plot": plot,
        "plotoutline": plot,
        "title": title,
        "originaltitle": title,
        "duration": dur,
        "studio": '',
        "tagline": tagline,
        "writer": writer,
        "premiered": '',
        "code": id,
        "credits": '',
        "votes": votes,
        "trailer": trailer
    }
    response = {
        "label": '%s (%s)' % (title, year),
        "originallabel": '%s (%s)' % (title, year),
        "poster": poster,
        "fanart_image": fanart,
        "imdbid": id,
        "year": year,
        "info": info
    }
    if cache:
        if getSetting("cachesites") == 'true':
            localdb.save_cache(id, '', '%s (%s)' % (title, year),
                               '%s (%s)' % (title, year), poster, fanart, year,
                               json.dumps(info), an)
    return response
def searchmovie(id,cache=True):
	basic.log(u"omdbapi.searchmovie id: %s" % id)
	listgenre = []
	listcast = []
	listcastr = []	
	genre = ''
	title = ''
	plot = ''
	tagline = ''
	director = ''
	writer = ''
	credits = ''
	poster = ''
	fanart = ''
	trailer = ''
	year = ''
	dur = 0
	if cache:
		if getSetting("cachesites") == 'true':
			cached = localdb.get_cache(id)
			if cached:
				response = { "label": cached[2], "originallabel": cached[3], "poster": cached[4], "fanart_image": cached[5], "imdbid": cached[0], "year": cached[6], "info": json.loads(cached[7]) }
				return response		
	jsonpage = basic.open_url(links.link().omdbapi_info % (id))
	jdef = json.loads(jsonpage)
	title = jdef['Title']
	poster = jdef['Poster']
	fanart = poster
	genre = jdef['Genre']
	plot = jdef['Plot']
	tagline = plot
	try: year = re.findall('(\d+)', jdef['Year'], re.DOTALL)[0]
	except: year = jdef['Year']
	listcast = jdef['Actors'].split(', ')
	director = jdef['Director']
	writer = jdef['Writer']
	duration = re.findall('(\d+) min', jdef['Runtime'], re.DOTALL)
	if duration: dur = int(duration[0])
	else: 
		duration = re.findall('(\d) h', jdef['Runtime'], re.DOTALL)
		if duration: dur = int(duration[0])*60
	info = {
			"genre": genre, 
			"year": year,
			"rating": jdef['imdbRating'], 
			"cast": listcast,
			"castandrole": listcast,
			"director": director,
			"plot": plot,
			"plotoutline": plot,
			"title": title,
			"originaltitle": title,
			"duration": dur,
			"studio": '',
			"tagline": tagline,
			"writer": writer,
			"premiered": '',
			"code": id,
			"credits": '',
			"votes": jdef['imdbVotes'],
			"trailer": ''
			}		
	response = {
		"label": '%s (%s)' % (title,year),
		"originallabel": '%s (%s)' % (title,year),
		"poster": poster,
		"fanart_image": fanart,
		"imdbid": id,
		"year": year,
		"info": info
		}
	if cache:
		if getSetting("cachesites") == 'true': localdb.save_cache(id,'','%s (%s)' % (title,year),'%s (%s)' % (originaltitle,year),poster,fanart,year,json.dumps(info))
	return response
Beispiel #3
0
Datei: tmdb.py Projekt: teosan5/0
def searchmovie(id):
    basic.log(u"tmdb.searchmovie id: %s" % id)
    listgenre = []
    listcast = []
    listcastr = []
    genre = ''
    title = ''
    plot = ''
    tagline = ''
    director = ''
    writer = ''
    credits = ''
    poster = ''
    fanart = ''
    temptitle = ''
    originaltitle = ''
    if getSetting("cachesites") == 'true':
        cached = localdb.get_cache(id)
        if cached:
            response = {
                "label": cached[2],
                "originallabel": cached[3],
                "poster": cached[4],
                "fanart_image": cached[5],
                "imdbid": cached[0],
                "year": cached[6],
                "info": json.loads(cached[7])
            }
            return response
    jsonpage = basic.open_url(links.link().tmdb_info_default % (id))
    try:
        jdef = json.loads(jsonpage)
    except:
        if 'tt' in str(id):
            try:
                jdef = omdbapi.searchmovie(str(id))
                return jdef
            except:
                return False
        else:
            return False
    if LANG <> 'en':
        try:
            jsonpage = basic.open_url(links.link().tmdb_info % (id, LANG))
            j = json.loads(jsonpage)
            temptitle = j['title'].encode('ascii', 'ignore').replace(' ', '')
            if temptitle <> '': title = j['title']
            fanart = links.link().tmdb_backdropbase % (j["backdrop_path"])
            poster = links.link().tmdb_posterbase % (j["poster_path"])
            for g in j['genres']:
                listgenre.append(g['name'])
            genre = ', '.join(listgenre)
            try:
                plot = j['overview']
            except:
                pass
            try:
                tagline = j['tagline']
            except:
                pass
            fanart = j["backdrop_path"]
            poster = j["poster_path"]
        except:
            pass
    temptitle = jdef['title'].encode('ascii', 'ignore').replace(' ', '')
    if temptitle <> '':
        if not title: title = jdef['title']
    temporiginaltitle = jdef['original_title'].encode('ascii', 'ignore')
    if temptitle == '': originaltitle = jdef['title']
    if temporiginaltitle == '': originaltitle = jdef['title']
    else: originaltitle = jdef['original_title']
    if not poster: poster = jdef['poster_path']
    if not fanart: fanart = jdef['backdrop_path']
    if not fanart: fanart = poster
    if fanart: fanart = links.link().tmdb_backdropbase % (fanart)
    if poster: poster = links.link().tmdb_posterbase % (poster)
    if genre == '':
        for g in jdef['genres']:
            listgenre.append(g['name'])
        genre = ', '.join(listgenre)
    if not plot: plot = jdef['overview']
    if not tagline: tagline = jdef['tagline']
    try:
        trailer = links.link().youtube_plugin % (
            jdef['trailers']['youtube'][0]['source'])
    except:
        trailer = ''
    try:
        year = jdef["release_date"].split("-")[0]
    except:
        year = ''
    try:
        studio = jdef['production_companies'][0]['name']
    except:
        studio = ''
    for listc in jdef['credits']['cast']:
        listcastr.append(listc['name'] + '|' + listc['character'])
        listcast.append(listc['name'])
    for crew in jdef['credits']['crew']:
        if crew['job'] == 'Director': director = crew['name']
        break
    for crew in jdef['credits']['crew']:
        if crew['job'] == 'Story': credits = crew['name']
        break
    for crew in jdef['credits']['crew']:
        if crew['job'] == 'Writer':
            writer = crew['name']
            break
        if crew['job'] == 'Novel':
            writer = crew['name']
            break
        if crew['job'] == 'Screenplay':
            writer = crew['name']
            break
    duration = jdef['runtime']
    if not poster or duration == 0 and jdef['imdb_id']:
        altsearch = omdbapi.searchmovie(jdef['imdb_id'], False)
        if not poster: poster = altsearch['poster']
        if not fanart: fanart = poster
        if not plot: plot = altsearch['info']['plot']
        if not tagline: tagline = altsearch['info']['plot']
        if not listcast:
            listcast = altsearch['info']['cast']
            listcastr = []
        if not duration: duration = altsearch['info']['duration']
        if not writer: writer = altsearch['info']['writer']
        if not director: director = altsearch['info']['director']
        if not genre: genre = altsearch['info']['genre']
    info = {
        "genre": genre,
        "year": year,
        "rating": jdef['vote_average'],
        "cast": listcast,
        "castandrole": listcastr,
        "director": director,
        "plot": plot,
        "plotoutline": plot,
        "title": title,
        "originaltitle": originaltitle,
        "duration": duration,
        "studio": studio,
        "tagline": tagline,
        "writer": writer,
        "premiered": jdef['release_date'],
        "code": jdef['imdb_id'],
        "credits": credits,
        "votes": jdef['vote_count'],
        "trailer": trailer
    }
    response = {
        "label": '%s (%s)' % (title, year),
        "originallabel": '%s (%s)' % (originaltitle, year),
        "poster": poster,
        "fanart_image": fanart,
        "imdbid": jdef['imdb_id'],
        "year": year,
        "info": info
    }
    if getSetting("cachesites") == 'true':
        if not str(id).startswith('tt'): tmdbid = id
        else: tmdbid = jdef['id']
        localdb.save_cache(jdef['imdb_id'], tmdbid, '%s (%s)' % (title, year),
                           '%s (%s)' % (originaltitle, year), poster, fanart,
                           year, json.dumps(info))
    return response
Beispiel #4
0
def searchmovie(id, an=None, cache=True):
    basic.log(u"cnmginfo.searchmovie id: %s" % id)
    genre = ''
    title = ''
    plot = ''
    tagline = ''
    director = ''
    writer = ''
    credits = ''
    poster = ''
    fanart = ''
    trailer = ''
    year = ''
    dur = 0
    if cache:
        if getSetting("cachesites") == 'true':
            cached = localdb.get_cache(id, an)
            if cached:
                response = {
                    "label": cached[2],
                    "originallabel": cached[3],
                    "poster": cached[4],
                    "fanart_image": cached[5],
                    "imdbid": cached[0],
                    "year": cached[6],
                    "info": json.loads(cached[7])
                }
                return response
    ordine = id[0]
    imagine = id[1]
    nume = id[2]
    an = id[3]
    regia = re.sub('Regia: ', '', striphtml(id[4])) if id[4] else ''
    actori = re.sub('Cu: ', '', striphtml(id[5])) if id[5] else ''
    gen = striphtml(id[6])
    nota = re.sub('IMDB: ', '', id[7])
    descriere = id[8]
    id = '1'
    try:
        nume = nume.decode('utf-8')
    except:
        nume = nume
    jdef = {
        'Title': nume,
        'Poster': imagine,
        'Genre': gen,
        'Plot': descriere,
        'Year': an,
        'Actors': actori,
        'Director': regia,
        'Writer': '',
        'Runtime': '',
        'imdbRating': nota,
        'imdbVotes': ''
    }
    try:
        title = jdef['Title']
    except:
        title = nume
    try:
        poster = jdef['Poster']
    except:
        poster = imagine
    fanart = poster
    try:
        genre = jdef['Genre']
    except:
        genre = gen
    try:
        plot = jdef['Plot']
    except:
        plot = descriere
    tagline = plot
    try:
        year = re.findall('(\d+)', jdef['Year'], re.DOTALL)[0]
    except:
        try:
            year = jdef['Year']
        except:
            year = an
    try:
        listcast = jdef['Actors'].split(', ')
    except:
        listcast = actori
    try:
        director = jdef['Director']
    except:
        director = regia
    try:
        writer = jdef['Writer']
    except:
        writer = ''
    try:
        duration = re.findall('(\d+) min', jdef['Runtime'], re.DOTALL)
        if duration: dur = int(duration[0])
        else:
            duration = re.findall('(\d) h', jdef['Runtime'], re.DOTALL)
            if duration: dur = int(duration[0]) * 60
    except:
        duration = ''
    try:
        rating = jdef['imdbRating']
    except:
        rating = nota
    try:
        votes = jdef['imdbVotes']
    except:
        votes = ''
    info = {
        "genre": genre,
        "year": year,
        "rating": rating,
        "cast": listcast,
        "castandrole": listcast,
        "director": director,
        "plot": plot,
        "plotoutline": plot,
        "title": title,
        "originaltitle": title,
        "duration": dur,
        "studio": '',
        "tagline": tagline,
        "writer": writer,
        "premiered": '',
        "code": id,
        "credits": '',
        "votes": votes,
        "trailer": ''
    }
    response = {
        "label": '%s (%s)' % (title, year),
        "originallabel": '%s (%s)' % (title, year),
        "poster": poster,
        "fanart_image": fanart,
        "imdbid": id,
        "year": year,
        "info": info
    }
    #if cache:
    #if getSetting("cachesites") == 'true': localdb.save_cache(id,'','%s (%s)' % (title,year),'%s (%s)' % (title,year),poster,fanart,year,json.dumps(info),an)
    return response
Beispiel #5
0
def searchmovie(id):
    basic.log(u"tmdb.searchmovie id: %s" % id)
    listgenre = []
    listcast = []
    listcastr = []
    genre = ""
    title = ""
    plot = ""
    tagline = ""
    director = ""
    writer = ""
    credits = ""
    poster = ""
    fanart = ""
    temptitle = ""
    originaltitle = ""
    if getSetting("cachesites") == "true":
        cached = localdb.get_cache(id)
        if cached:
            response = {
                "label": cached[2],
                "originallabel": cached[3],
                "poster": cached[4],
                "fanart_image": cached[5],
                "imdbid": cached[0],
                "year": cached[6],
                "info": json.loads(cached[7]),
            }
            return response
    jsonpage = basic.open_url(links.link().tmdb_info_default % (id))
    try:
        jdef = json.loads(jsonpage)
    except:
        if "tt" in str(id):
            try:
                jdef = omdbapi.searchmovie(str(id))
                return jdef
            except:
                return False
        else:
            return False
    if LANG <> "en":
        try:
            jsonpage = basic.open_url(links.link().tmdb_info % (id, LANG))
            j = json.loads(jsonpage)
            temptitle = j["title"].encode("ascii", "ignore").replace(" ", "")
            if temptitle <> "":
                title = j["title"]
            fanart = links.link().tmdb_backdropbase % (j["backdrop_path"])
            poster = links.link().tmdb_posterbase % (j["poster_path"])
            for g in j["genres"]:
                listgenre.append(g["name"])
            genre = ", ".join(listgenre)
            try:
                plot = j["overview"]
            except:
                pass
            try:
                tagline = j["tagline"]
            except:
                pass
            fanart = j["backdrop_path"]
            poster = j["poster_path"]
        except:
            pass
    temptitle = jdef["title"].encode("ascii", "ignore").replace(" ", "")
    if temptitle <> "":
        if not title:
            title = jdef["title"]
    temporiginaltitle = jdef["original_title"].encode("ascii", "ignore")
    if temptitle == "":
        originaltitle = jdef["title"]
    if temporiginaltitle == "":
        originaltitle = jdef["title"]
    else:
        originaltitle = jdef["original_title"]
    if not poster:
        poster = jdef["poster_path"]
    if not fanart:
        fanart = jdef["backdrop_path"]
    if not fanart:
        fanart = poster
    if fanart:
        fanart = links.link().tmdb_backdropbase % (fanart)
    if poster:
        poster = links.link().tmdb_posterbase % (poster)
    if genre == "":
        for g in jdef["genres"]:
            listgenre.append(g["name"])
        genre = ", ".join(listgenre)
    if not plot:
        plot = jdef["overview"]
    if not tagline:
        tagline = jdef["tagline"]
    try:
        trailer = links.link().youtube_plugin % (jdef["trailers"]["youtube"][0]["source"])
    except:
        trailer = ""
    try:
        year = jdef["release_date"].split("-")[0]
    except:
        year = ""
    try:
        studio = jdef["production_companies"][0]["name"]
    except:
        studio = ""
    for listc in jdef["credits"]["cast"]:
        listcastr.append(listc["name"] + "|" + listc["character"])
        listcast.append(listc["name"])
    for crew in jdef["credits"]["crew"]:
        if crew["job"] == "Director":
            director = crew["name"]
        break
    for crew in jdef["credits"]["crew"]:
        if crew["job"] == "Story":
            credits = crew["name"]
        break
    for crew in jdef["credits"]["crew"]:
        if crew["job"] == "Writer":
            writer = crew["name"]
            break
        if crew["job"] == "Novel":
            writer = crew["name"]
            break
        if crew["job"] == "Screenplay":
            writer = crew["name"]
            break
    duration = jdef["runtime"]
    if not poster or duration == 0 and jdef["imdb_id"]:
        altsearch = omdbapi.searchmovie(jdef["imdb_id"], False)
        if not poster:
            poster = altsearch["poster"]
        if not fanart:
            fanart = poster
        if not plot:
            plot = altsearch["info"]["plot"]
        if not tagline:
            tagline = altsearch["info"]["plot"]
        if not listcast:
            listcast = altsearch["info"]["cast"]
            listcastr = []
        if not duration:
            duration = altsearch["info"]["duration"]
        if not writer:
            writer = altsearch["info"]["writer"]
        if not director:
            director = altsearch["info"]["director"]
        if not genre:
            genre = altsearch["info"]["genre"]
    info = {
        "genre": genre,
        "year": year,
        "rating": jdef["vote_average"],
        "cast": listcast,
        "castandrole": listcastr,
        "director": director,
        "plot": plot,
        "plotoutline": plot,
        "title": title,
        "originaltitle": originaltitle,
        "duration": duration,
        "studio": studio,
        "tagline": tagline,
        "writer": writer,
        "premiered": jdef["release_date"],
        "code": jdef["imdb_id"],
        "credits": credits,
        "votes": jdef["vote_count"],
        "trailer": trailer,
    }
    response = {
        "label": "%s (%s)" % (title, year),
        "originallabel": "%s (%s)" % (originaltitle, year),
        "poster": poster,
        "fanart_image": fanart,
        "imdbid": jdef["imdb_id"],
        "year": year,
        "info": info,
    }
    if getSetting("cachesites") == "true":
        if not str(id).startswith("tt"):
            tmdbid = id
        else:
            tmdbid = jdef["id"]
        localdb.save_cache(
            jdef["imdb_id"],
            tmdbid,
            "%s (%s)" % (title, year),
            "%s (%s)" % (originaltitle, year),
            poster,
            fanart,
            year,
            json.dumps(info),
        )
    return response
def searchmovie(id, cache=True):
    basic.log(u"omdbapi.searchmovie id: %s" % id)
    listgenre = []
    listcast = []
    listcastr = []
    genre = ''
    title = ''
    plot = ''
    tagline = ''
    director = ''
    writer = ''
    credits = ''
    poster = ''
    fanart = ''
    trailer = ''
    year = ''
    dur = 0
    if cache:
        if getSetting("cachesites") == 'true':
            cached = localdb.get_cache(id)
            if cached:
                response = {
                    "label": cached[2],
                    "originallabel": cached[3],
                    "poster": cached[4],
                    "fanart_image": cached[5],
                    "imdbid": cached[0],
                    "year": cached[6],
                    "info": json.loads(cached[7])
                }
                return response
    jsonpage = basic.open_url(links.link().omdbapi_info % (id))
    jdef = json.loads(jsonpage)
    title = jdef['Title']
    poster = jdef['Poster']
    fanart = poster
    genre = jdef['Genre']
    plot = jdef['Plot']
    tagline = plot
    try:
        year = re.findall('(\d+)', jdef['Year'], re.DOTALL)[0]
    except:
        year = jdef['Year']
    listcast = jdef['Actors'].split(', ')
    director = jdef['Director']
    writer = jdef['Writer']
    duration = re.findall('(\d+) min', jdef['Runtime'], re.DOTALL)
    if duration: dur = int(duration[0])
    else:
        duration = re.findall('(\d) h', jdef['Runtime'], re.DOTALL)
        if duration: dur = int(duration[0]) * 60
    info = {
        "genre": genre,
        "year": year,
        "rating": jdef['imdbRating'],
        "cast": listcast,
        "castandrole": listcast,
        "director": director,
        "plot": plot,
        "plotoutline": plot,
        "title": title,
        "originaltitle": title,
        "duration": dur,
        "studio": '',
        "tagline": tagline,
        "writer": writer,
        "premiered": '',
        "code": id,
        "credits": '',
        "votes": jdef['imdbVotes'],
        "trailer": ''
    }
    response = {
        "label": '%s (%s)' % (title, year),
        "originallabel": '%s (%s)' % (title, year),
        "poster": poster,
        "fanart_image": fanart,
        "imdbid": id,
        "year": year,
        "info": info
    }
    if cache:
        if getSetting("cachesites") == 'true':
            localdb.save_cache(id, '', '%s (%s)' % (title, year),
                               '%s (%s)' % (originaltitle, year), poster,
                               fanart, year, json.dumps(info))
    return response