• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Movie类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Movie的典型用法代码示例。如果您正苦于以下问题:Python Movie类的具体用法?Python Movie怎么用?Python Movie使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: get

    def get(self, name):
        if not users.get_current_user():
            self.redirect(users.create_login_url(self.request.uri))

        results = search_metacritic(name, 'movie')

        output = []

        for result in results:
            query = Img.all()
            query.filter('url =', result[1])
            img = query.fetch(1)[0]
            query = Movie.all()
            query.filter('cover =', img)
            if not query.count():
                movie = Movie(name=str(result[0]),cover=img,score=str(result[2]))
                movie.put()
            else:
                movie = query.fetch(1)[0]
            output.append([img.key().id(), result[0], movie.key().id()])

        template_values = {'results': output}

        path = os.path.join(os.path.dirname(__file__), 'search.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:fabiomdiniz,项目名称:arcateca,代码行数:25,代码来源:views.py


示例2: users_get

 def users_get(self, request):
     """Exposes an API endpoint to obtain the details of the User
     Args:
         request: Void message request, because the info comes from the JWT
     Returns:
         An Instance containing the User Details.
     """
     #get jwt and validates if user exists
     selected_user = self.validate_jwtoken(self.request_state)
     
     list_of_voted_movies_query = MovieRankingUser.query(MovieRankingUser.user==selected_user.key).fetch()
     list_of_voted_movies = []
     list_of_voted_movie_keys_to_exclude = []
     for user_movie_relation in list_of_voted_movies_query:
         current_movie = Movie.query(Movie.key==user_movie_relation.movie).get()
         list_of_voted_movies.append(current_movie.to_message())
         #puts the voted movie keys in a list to exclude
         list_of_voted_movie_keys_to_exclude.append(current_movie.key)
         
     #all movies in the system
     total_list_of_movies = Movie.query().order(Movie.title)
     #removes the voted movies from the total
     list_of_not_voted_movies_query = [res for res in total_list_of_movies.fetch() if res.key not in list_of_voted_movie_keys_to_exclude]
     #transforms the movies to messages
     list_of_not_voted_movies = [system_movie.to_message() for system_movie in list_of_not_voted_movies_query]
     return selected_user.to_message(votes_movies=list_of_voted_movies, not_votes_movies=list_of_not_voted_movies)
开发者ID:xmaps,项目名称:movie-ranking-test,代码行数:26,代码来源:movie_ranking_api.py


示例3: movies_vote

 def movies_vote(self, request):
     """Exposes an API endpoint to insert the new votes from the user
     Args:
         request: A list of the movies the user currently likes and cast a vote.
     Returns:
         A void message if everthing goes well or an error.
     """
     #get jwt and validates if user exists
     selected_user = self.validate_jwtoken(self.request_state)
     
     list_of_voted_movies_query = MovieRankingUser.query(MovieRankingUser.user==selected_user.key).fetch()
     for user_movie_relation in list_of_voted_movies_query:
         current_movie = Movie.query(Movie.key==user_movie_relation.movie).get()
         current_counter = current_movie.number_of_users_who_voted
         current_movie.number_of_users_who_voted = current_counter - 1
         current_movie.put()
         user_movie_relation.key.delete()
         
     for voted_movie in request.voted_movies:
         current_movie = Movie.get_by_id(voted_movie.movie_identifier)
         current_counter = current_movie.number_of_users_who_voted
         current_movie.number_of_users_who_voted = current_counter + 1
         new_movie_user_vote = MovieRankingUser(user=selected_user.key,movie=current_movie.key)
         current_movie.put()
         new_movie_user_vote.put()
     return VoteResponse(status_msg='Vote casted with success.')
开发者ID:xmaps,项目名称:movie-ranking-test,代码行数:26,代码来源:movie_ranking_api.py


示例4: start_tr

    def start_tr(self, attrs):
        if self.break_tag == True:
            return

        if self.start_tag == True and self.tbody_tag == True:
            movie = Movie()
            movie.movie_status = 'new'
            movie.movie_magnet_count = 0
            self.movies.append(movie)
开发者ID:liyunhai,项目名称:res-auto,代码行数:9,代码来源:htmlparser.py


示例5: create

 def create(self):
     if request.method == 'POST':
         if request.form.get('message'):
             Movie.create(
                 title=request.form['title'],
                 release=request.form['release'],
                 description=request.form['description'],
                 poster=request.form['poster']
             )
     next = request.form.get('next') or self.dashboard_url()
     return redirect(next)
开发者ID:dommert,项目名称:DangerZone,代码行数:11,代码来源:admin.py


示例6: getDetails

def getDetails(identifiers):
	try:
		movie=Movie.objects.get(sourceID=identifiers.sourceID,source=identifiers.source)
	except:
		movie=Movie()
		if identifiers.source=='rottenTomatoes':
			movie=fetchDetailsRottenTomatoes(identifiers)
		elif identifiers.source=='theMovieDB':
			movie=fetchDetailsTheMovieDB(identifiers)
		movie.save()
	return movie	
开发者ID:ebarakos,项目名称:movie-aggregator,代码行数:11,代码来源:utils.py


示例7: saveMovie

def saveMovie (request):
    channel=Channel.objects.get(id=1)
    html = urllib.urlopen('http://sh.meituan.com/dianying').read()
    soup = BeautifulSoup(html)
    for movie in soup.find_all('ul', class_='reco-slides__slides')[0].find_all('li')[0].find_all('a',class_='btn'):
        name = movie['title']
        href = movie['href']
        code = href[href.rfind('/') + 1:href.find('#')]
        m = Movie(name=name,code=code,channel=channel)
        m.save()
    return HttpResponse("save success! ")
开发者ID:unluckyBear,项目名称:django,代码行数:11,代码来源:views.py


示例8: post

    def post(self):
        title = self.request.get("title")
        url = self.request.get("url")
        rate = self.request.get("rate")

        movie = Movie(title=title,url=url,rate=rate)
        movie.put()


        params = {"title":title,"url":url,"movie":movie,"rate":rate}
        self.render_template("film_izpis.html",params=params)
开发者ID:matejagustin,项目名称:base_jinja,代码行数:11,代码来源:main.py


示例9: add_movie

def add_movie():
    title = request.form.get('title')
    imdb_id = request.form.get('imdb_id')
    if title is not None and imdb_id is not None:
        url = "http://www.imdb.com/title/" + imdb_id
        img_src = get_img_url(url)
        movie = Movie(title=title, imdb_id=imdb_id, url=url, img_src=img_src, votes=0)
        Session().add(movie)
        Session().commit()

        return flask.jsonify(movie.as_dict()), 201
    else:
        return "Invalid request", 400
开发者ID:danihodovic,项目名称:movlist-react-typescript,代码行数:13,代码来源:main.py


示例10: retrieve_movie_from_id

def retrieve_movie_from_id(movie_id):
    """
    Retrieve movie info from IMDB by movie id.
    :param movie_id: original title of the film to retrieve info
    :type movie_id: string
    :return: Movie's key
    :rtype: ndb.Key
    :raise RetrieverError: if there is an error from MYAPIFILMS
    """
    logging.info('Retrieving %s', movie_id)

    url = BASE_URL_MYAPIFILMS + 'imdb?idIMDB=' + movie_id + '&format=JSON&aka=1&business=0&seasons=0&seasonYear=0&technical=0&filter=N&exactFilter=0&limit=1&lang=en-us&actors=S&biography=0&trailer=1&uniqueName=0&filmography=0&bornDied=0&starSign=0&actorActress=0&actorTrivia=0&movieTrivia=0&awards=0&token=307cccfe-d20b-4b69-b976-d6a024538864'

    json_page = get(url).encode('utf-8')
    json_data = json.loads(json_page)

    movie = Movie(id=json_data['idIMDB'],
                  plot=json_data['plot'],
                  poster=clear_url(json_data['urlPoster']) if ('urlPoster' in json_data and json_data['urlPoster'] != "") else None,
                  rated=json_data['rated'],
                  simple_plot=json_data['simplePlot'],
                  genres=json_data['genres'])

    try:
        trailer_url = json_data['trailer']['videoURL']
        movie.trailer = trailer_url
    except KeyError:
        movie.trailer = None

    movie.original_title = json_data['title']

    akas = json_data['akas']
    for aka in akas:
        if aka['country'] == 'Italy':
            movie.title = aka['title']

    run_times = json_data['runtime']
    if len(run_times) == 0:
        movie.run_times = None
    else:
        movie.run_times = run_times[0]

    year = json_data['year']
    if len(year) > 4:
        year = year[-4:]

    movie.year = year
    key = movie.put()
    actors_list = json_data['actors']
    directors_list = json_data['directors']
    writers_list = json_data['writers']

    retrieve_artists(movie, actors_list, directors_list, writers_list)

    logging.info('Retrieved %s', movie_id)
    return key
开发者ID:PRIMETIME4U,项目名称:PRIMETIME4U-server,代码行数:56,代码来源:IMDB_retriever.py


示例11: get_movie

def get_movie(request, pk):
    """
    function to handle request for a particular movie
    GET => uesd to query
    POST w/o id, to insert and return inserted value
    POST w/ id, to update existing record
    :param request: incomming http request
    :param pk: primary key of the movie requested
    :return:
    """
    #check the incomming method
    try:
        if request.method == "GET":
            if pk != '':
                _movie = Movie.objects.get(pk=pk).json()
                response = HttpResponse(_movie, content_type="application/json")
                return response
            else:
                response = search_movie(request)
                return response
                raise Movie.MultipleObjectsReturned()
        elif request.method == 'POST':
            #check if user is authenticated to touch it
            #if pk='', insert, else overwrite
            if pk == '' and has_perm(request, 'IMDB.create_movie'):
                _m = Movie()
            elif pk != '' and has_perm(request, 'IMDB.change_movie'):
                _m = get_object_or_404(Movie, pk=pk)
            else:
                raise PermissionDenied()
            _m.add_using_json(request.body)
            _m.save()
            return HttpResponse(_m.json(), content_type="application/json", status=201)
        elif request.method == 'DELETE':
            if pk != '':
                if has_perm(request, 'delete_movie'):
                    _m = get_object_or_404(Movie, pk=pk)
                    _m.delete()
                    return HttpResponse('delete successful', content_type="application/json", status=200)
                else:
                    raise PermissionDenied()
            else:
                raise Movie.MultipleObjectsReturned()
        else:
            raise Movie.MultipleObjectsReturned()  #avoiding modification to the entire series
    except IntegrityError as ie:
        return HttpResponseBadRequest("{'status':400,'message':'Bad Request -- Integrity violation:" + ie.message + "'}",
                                        content_type="application/json")
    except KeyError as k:
        return HttpResponseBadRequest("{'status':400,'message':'Bad Request -- Key violation:" + k.message + "'}",
                                      content_type="application/json")
    except Movie.MultipleObjectsReturned as e:
        return HttpResponseNotFound(json.dumps({'status': 404, 'message': 'movie not found'}),
                                    content_type="application/json")
    except (Movie.DoesNotExist, Http404):
        return HttpResponseNotFound(json.dumps({'status': 404, 'message': 'movie not found'}),
                                    content_type="application/json")
    except PermissionDenied as p:
        return HttpResponseForbidden(json.dumps({'status': 403, 'message': 'Permission Denied{0:s}'.format(p.message)}),
                                     content_type="application/json")
开发者ID:jiteshpunjabi,项目名称:movie-rest-api,代码行数:60,代码来源:views.py


示例12: add_movie

def add_movie():
    input_title = flask.request.values['title']

    if not input_title:
        flask.flash('Blank movie title.', 'danger')

    else:
        imdb = imdbpie.Imdb()

        # first we check if input_title is an id or URL:
        movie_id = imdb.validate_id(input_title)
        if not movie_id:
            title = imdb.find_by_title(input_title)
            if title:
                movie_id = title[0]['imdb_id']

        if movie_id:
            movie_info = imdb.find_movie_by_id(movie_id)
            new_movie = Movie.create_scheduled(
                title=movie_info.title,
                year=movie_info.year,
                imdb_id=movie_info.imdb_id,
                imdb_rating=movie_info.rating,
                imdb_cover_url=movie_info.data['image']['url']
            )

            flask.flash('Movie "{}" was added.'.format(new_movie['title']), 'success')

    return flask.redirect(flask.url_for('admin'))
开发者ID:gediminasz,项目名称:movieoftheweek,代码行数:29,代码来源:app.py


示例13: add_movie_tastes

def add_movie_tastes(user_id, movie_id, taste):

        taste = float(taste)
        user = User.get_by_id(user_id)
        movie = Movie.get_by_id(movie_id)
        for actor in movie.actors:
            artist = Artist.get_by_id(actor.id())
            user.add_taste_artist(artist, ACTOR_WEIGHT * taste)

        for director in movie.directors:
            artist = Artist.get_by_id(director.id())
            user.add_taste_artist(artist, DIRECTOR_WEIGHT * taste)

        for writer in movie.writers:
            artist = Artist.get_by_id(writer.id())
            user.add_taste_artist(artist, WRITER_WEIGHT * taste)

        for genre in movie.genres:
            user.add_taste_genre(genre, GENRE_WEIGHT * taste)

        user.remove_proposal()
        user.put()
        taskqueue.add(url='/api/proposal/' + user.key.id(), method='GET')


        return 'OK'
开发者ID:PRIMETIME4U,项目名称:PRIMETIME4U-server,代码行数:26,代码来源:task.py


示例14: save

    def save(guess, user_id, movie_id):
        user = User.from_id(user_id)
        rating = Movie.from_id(movie_id).rating
        guess_id = None

        connection = connect()
        try:
            with connection.cursor() as cursor:
                sql = """INSERT INTO `guesses` (guess, user_id, movie_id, diff)
                    VALUES (%s, %s, %s, %s)"""
                cursor.execute(
                    sql,
                    (
                        guess,
                        user_id,
                        movie_id,
                        Guess.calculate_score(rating, guess)
                    )
                )
                guess_id = cursor.lastrowid

                sql = """SELECT SUM(`diff`) AS score
                    FROM `guesses` WHERE `user_id`=%s"""
                cursor.execute(sql, (user_id))
                result = cursor.fetchone()

                user.score = result[u'score']

            connection.commit()

        finally:
            connection.close()

        user.update()
        return Guess.from_id(guess_id)
开发者ID:MimmiTh,项目名称:movie-rank-guess-game,代码行数:35,代码来源:guess.py


示例15: post_comment

def post_comment():
    title = request.form['title']
    contents = request.form['contents']
    if contents:
        m = Movie.get_or_create(title)
        m.add_comment(Comment(user_id=g.user.id, contents=contents))
    return redirect(url_for("show_movie", title=title))
开发者ID:lost-theory,项目名称:moviepicker,代码行数:7,代码来源:app.py


示例16: test_serialize_unicode

    def test_serialize_unicode(self):
        """Tests that unicode makes the roundtrip intact"""
        actor_name = u"Za\u017c\u00f3\u0142\u0107"
        movie_title = u'G\u0119\u015bl\u0105 ja\u017a\u0144'
        ac = Actor(name=actor_name)
        mv = Movie(title=movie_title, actor=ac)
        ac.save()
        mv.save()

        serial_str = serializers.serialize(self.serializer_name, [mv])
        self.assertEqual(self._get_field_values(serial_str, "title")[0], movie_title)
        self.assertEqual(self._get_field_values(serial_str, "actor")[0], actor_name)

        obj_list = list(serializers.deserialize(self.serializer_name, serial_str))
        mv_obj = obj_list[0].object
        self.assertEqual(mv_obj.title, movie_title)
开发者ID:Terhands,项目名称:django,代码行数:16,代码来源:tests.py


示例17: get_tastes_movies_list

def get_tastes_movies_list(user, page=0):
    """
    Get a readable taste movies list.
    :param user: user
    :type user: Models.User
    :return: list of tastes
        {"code": 0, "data": {"tastes": [{"idIMDB": id,"originalTitle": original_title, "poster": poster_url}],
        "type": type, "userId": user_id}
    :rtype: JSON
    """
    tastes_movies_id = user.tastes_movies

    movies = []

    for taste_movie_id in tastes_movies_id:
        taste_movie = TasteMovie.get_by_id(taste_movie_id.id())  # Get taste
        if taste_movie.taste >= 1 and taste_movie.added:
            movie_id = taste_movie.movie.id()  # Get movie id from taste
            movie = Movie.get_by_id(movie_id)  # Get movie by id

            movies.append({"idIMDB": movie_id,
                       "originalTitle": movie.original_title.encode('utf-8') if movie.original_title is not None else None,
                       "title": movie.title.encode('utf-8') if movie.title is not None else None,
                       "tasted": 1,
                       "poster": movie.poster})

    return jsonify(code=0, data={"userId": user.key.id(), "type": "movie", "tastes": movies})
开发者ID:PRIMETIME4U,项目名称:PRIMETIME4U-server,代码行数:27,代码来源:api.py


示例18: getMovies

def getMovies():
    movies = []

    sel_mov = Movie.select()

    for mov in sel_mov:
        movies.append(mov.__dict__['_data'])

    return jsonify(movies)
开发者ID:EverlessDrop41,项目名称:flask-movie-site,代码行数:9,代码来源:views.py


示例19: insert_movie

def insert_movie(the_movie):
    movie = Movie.from_tmdb(the_movie, True)
    db_session.add(movie)
    try:
        db_session.commit()
        return movie.movieid
    except:
        db_session.rollback()
        raise
开发者ID:pulmro,项目名称:moviecase,代码行数:9,代码来源:db_methods.py


示例20: load_sample_data

def load_sample_data():
    file_path = os.path.abspath('/home/jiteshvp/Dev/ShopSense/InterviewExercise/data/imdb.json')
    with open(file_path, 'r') as f:
        _decoded_json = json.load(f)
        for _json_movie in _decoded_json:
            _movie = Movie(
                popularity=unicode_lower_strip(_json_movie['99popularity']),
                director=unicode_lower_strip(_json_movie['director']),
                movie_name=unicode_lower_strip(_json_movie['name'])
            )
            try:
                _movie.save()
                for _json_genre in _json_movie['genre']:
                    (_genre, _was_created) = Genre.objects.get_or_create(genre_label=unicode_lower_strip(_json_genre))
                    _movie.genre.add(_genre)
                _movie.save()
            except Exception as e:
                pass
开发者ID:jiteshpunjabi,项目名称:movie-rest-api,代码行数:18,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.News类代码示例发布时间:2022-05-27
下一篇:
Python models.Move类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap