当前位置: 首页>>代码示例>>Python>>正文


Python imdb.IMDb方法代码示例

本文整理汇总了Python中imdb.IMDb方法的典型用法代码示例。如果您正苦于以下问题:Python imdb.IMDb方法的具体用法?Python imdb.IMDb怎么用?Python imdb.IMDb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在imdb的用法示例。


在下文中一共展示了imdb.IMDb方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def handle(text, mic, profile):
    mic.say('What movie?')
    movie_name = mic.activeListen()
    mic.say('Searching top five results for.  %s' %movie_name)
    ia = IMDb()
    movie_query = ia.search_movie(movie_name)
    del movie_query[5:]
    for movie in movie_query:
        mic.say('Did you mean %s (%s)?' %(movie.get('title'), movie.get('year')))
        response = mic.activeListen()
        if yes(response):
            ia.update(movie)
            movie_info = '%s (%s).  ' %(movie.get('title'), movie.get('year'))
            if movie.get('rating'): movie_info += 'Rating.  %s out of 10.  ' %movie.get('rating')
            if movie.get('runtimes'): movie_info += 'Runtime.  %s minutes.  ' %movie.get('runtimes')[0]
            if movie.get('genres'): movie_info += 'Genres.  %s.  ' %'.  '.join(movie.get('genres'))
            if movie.get('plot outline'): movie_info += 'Plot.  %s  ' %movie.get('plot outline')
            if movie.get('director'): movie_info += 'Directors.  %s.  ' %format_names(movie.get('director'))
            if movie.get('producer'): movie_info += 'Producers.  %s.  ' %format_names(movie.get('producer'))
            if movie.get('cast'): movie_info += 'Cast.  %s.  ' %format_names(movie.get('cast'))
            mic.say(movie_info)
            return
    mic.say('Unable to find information on the requested movie') 
开发者ID:mattcurrycom,项目名称:jasper-modules,代码行数:25,代码来源:Movies.py

示例2: main

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def main(movie):
    app = imdb.IMDb()
    results = app.search_movie(movie)
    if not results:
        return "error 404"
    first = results[0]
    ID = first.movieID
    data = app.get_movie(ID)
    return data 
开发者ID:sukeesh,项目名称:Jarvis,代码行数:11,代码来源:movie.py

示例3: trivia

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def trivia(movie):
	movie = titlecheck(movie)
        if ("ERROR: " in movie):
                return movie
        movie = movie.replace("movie.","")
	try:
		import imdb
	except Exception:
		return ("Error: You must install the imdbpy library to use this action.")
	i = imdb.IMDb()
	movie = movie.strip()
	mvlst = i.search_movie(movie)
	mve = mvlst[0]
	i.update(mve)
	i.update(mve, 'trivia')
	try:
		tlist = mve['trivia']
	except Exception:
		return ("No trivia options available for this option.")
	min = 0
	max = len(mve['trivia'])
	rand = randint(min,max)
	return (tlist[rand]) 
开发者ID:MoeFwacky,项目名称:Python-Plex-Controller,代码行数:25,代码来源:system.py

示例4: faqs

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def faqs(movie):
	movie = titlecheck(movie)
        if ("ERROR: " in movie):
                return movie
        movie = movie.replace("movie.","")
	try:
               import imdb
        except Exception:
               return ("Error: You must install the imdbpy library to use this action.")
        i = imdb.IMDb()
        movie = movie.strip()
        mvlst = i.search_movie(movie)
        mve = mvlst[0]
        i.update(mve)
        i.update(mve, ['faqs'])
        min = 0
        max = len(mve['faqs'])
        rand = randint(min,max)
        return (mve['faqs'][rand]) 
开发者ID:MoeFwacky,项目名称:Python-Plex-Controller,代码行数:21,代码来源:system.py

示例5: get_twitter_imdb_access

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def get_twitter_imdb_access():

    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    
    api = tweepy.API(auth)
    
    ia = imdb.IMDb()
    return api,ia 
开发者ID:Blueteak,项目名称:Movie-Success-Predictor,代码行数:11,代码来源:TwitterQuery.py

示例6: goofs

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def goofs(movie):
	try:
               import imdb
        except Exception:
               return ("Error: You must install the imdbpy library to use this action.")
        i = imdb.IMDb()
        movie = movie.strip()
        mvlst = i.search_movie(movie)
        mve = mvlst[0]
	i.update(mve)
        i.update(mve, 'all')
        min = 0
        max = len(mve['quotes'])
        rand = randint(min,max)
        return (mve['quotes'][rand]) 
开发者ID:MoeFwacky,项目名称:Python-Plex-Controller,代码行数:17,代码来源:system.py

示例7: main

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def main(argv=None):
    if not argv:
        argv = sys.argv
    s = Store()
    if argv[1] in ('help', '--help', 'h', '-h'):
        help()
    elif argv[1] == 'whoami':
        if os.path.exists(storefn):
            print(list(s.who())[0])
        else:
            s.who(argv[2])
    elif argv[1].startswith('http://www.imdb.com/title/tt'):
        if s.movie_is_in(argv[1]):
            raise
        else:
            i = imdb.IMDb()
            movie = i.get_movie(argv[1][len('http://www.imdb.com/title/tt'):-1])
            print('%s (%s)' % (movie['title'].encode('utf-8'), movie['year']))
            for director in movie['director']:
                print('directed by: %s' % director['name'].encode('utf-8'))
            for writer in movie['writer']:
                print('written by: %s' % writer['name'].encode('utf-8'))
            s.new_movie(movie)
            rating = None
            while not rating or (rating > 5 or rating <= 0):
                try:
                    rating = int(raw_input('Rating (on five): '))
                except ValueError:
                    rating = None
            date = None
            while not date:
                try:
                    i = raw_input('Review date (YYYY-MM-DD): ')
                    date = datetime.datetime(*time.strptime(i, '%Y-%m-%d')[:6])
                except:
                    date = None
            comment = raw_input('Comment: ')
            s.new_review(movie, date, rating, comment)
    else:
        help() 
开发者ID:GiovanniBalestrieri,项目名称:Meiji,代码行数:42,代码来源:film.py

示例8: whodirected

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def whodirected(xmovie):
	try:
                import imdb
        except Exception:
                return ("Error: You must install the imdbpy library to use this action.")
	i = imdb.IMDb()
	movie = xmovie.strip()
	mvlist = i.search_movie(movie)
        mve = mvlist[0]
	if ((mve.data['kind'] == "tv series") and ("-s" not in sys.argv)):
                        mve = mvlist[1]
        i.update(mve)
	nme = mve.data['director']
	direct = nme[0]
	return direct 
开发者ID:MoeFwacky,项目名称:Python-Plex-Controller,代码行数:17,代码来源:system.py

示例9: whoplayed

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def whoplayed(ctr, xmovie):
	try:
                import imdb
        except Exception:
                return ("Error: You must install the imdbpy library to use this action.")
        i = imdb.IMDb()
        movie = xmovie.strip()
	try:
		mvlist = i.search_movie(movie)
		mve = mvlist[0]
		if ((mve.data['kind'] == "tv series") and ("-s" not in sys.argv)):
			mve = mvlist[1]
	except Exception:
		return ("ERROR: " + xmovie + " not found.")
			
        i.update(mve)
	#print (mve.data['kind'])
	nme = mve.data['cast']
	for actr in nme:
		if str(actr.currentRole).lower() == str(ctr).lower():
			direct = actr
	try:
		direct
	except Exception:
		for actr in nme:
			#print str(actr.currentRole)
			if str(ctr).lower() in str(actr.currentRole).lower():
				direct = actr
	try:
		direct
	except Exception:
		if " " not in ctr:
			pass
		else:
			print ("Failed with given name. Trying a hail marry.")
			excludeme = ['a','the','of','for','at']
			ctst = ctr.split(" ")
			for itm in ctst:
				if itm in excludeme:
					pass
				else:
					for actr in nme:
						if str(itm).lower() in str(actr.currentRole).lower():
							direct = actr
				
	try:
		direct
	except Exception:
		direct = "ERROR: " + ctr + " Not Found in " + xmovie + "."

        return direct 
开发者ID:MoeFwacky,项目名称:Python-Plex-Controller,代码行数:53,代码来源:system.py

示例10: process

# 需要导入模块: import imdb [as 别名]
# 或者: from imdb import IMDb [as 别名]
def process(input, entities):
    output = {}
    try:
        movie = entities['movie'][0]['value']

        with requests_cache.enabled('movie_cache', backend='sqlite', expire_after=86400):
            # Make a search request to the API to get the movie's TMDb ID
            r = requests.get('http://api.themoviedb.org/3/search/movie', params={
                'api_key': TMDB_API_KEY,
                'query': movie,
                'include_adult': False
            })
            data = r.json()

            assert (len(data['results']) > 0)
            tmdb_id = str(data['results'][0]['id'])

            # Make another request to the API using the movie's TMDb ID to get the movie's IMDb ID
            r = requests.get('https://api.themoviedb.org/3/movie/' + tmdb_id, params={
                'api_key': TMDB_API_KEY,
                'append_to_response': 'videos'
            })
            data = r.json()

        # Fetch movie rating from IMDb
        ia = IMDb()
        imdb_id = data['imdb_id']
        imdb_movie = ia.get_movie(imdb_id[2:])

        template = TextTemplate('Title: ' + data['title'] +
                                '\nYear: ' + data['release_date'][:4] +
                                '\nIMDb Rating: ' + str(imdb_movie['rating']) + ' / 10' +
                                '\nOverview: ' + data['overview'])
        text = template.get_text()
        template = ButtonTemplate(text)
        template.add_web_url('IMDb Link', 'https://www.imdb.com/title/' + data['imdb_id'] + '/')

        videos = data['videos']['results']
        # Append first Trailer URL if one exists
        for video in videos:
            if video['type'] == 'Trailer' and video['site'] == 'YouTube':
                template.add_web_url('YouTube Trailer', YouTubeUtil.get_video_url(video['key']))
                break

        output['input'] = input
        output['output'] = template.get_message()
        output['success'] = True
    except:
        error_message = 'I couldn\'t find that movie.'
        error_message += '\nPlease ask me something else, like:'
        error_message += '\n  - batman movie'
        error_message += '\n  - iron man 2 movie plot'
        error_message += '\n  - What is the rating of happyness movie?'
        output['error_msg'] = TextTemplate(error_message).get_message()
        output['success'] = False
    return output 
开发者ID:swapagarwal,项目名称:JARVIS-on-Messenger,代码行数:58,代码来源:movie.py


注:本文中的imdb.IMDb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。