本文整理汇总了Python中movie.Movie类的典型用法代码示例。如果您正苦于以下问题:Python Movie类的具体用法?Python Movie怎么用?Python Movie使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Movie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMovieWeekend
def testMovieWeekend(self):
m = Movie(121, "Saturday", True, True)
m.addTicket(20,False)
price = m.finishPurchase()
self.assertEquals(price, 17.0)
示例2: MovieTest
class MovieTest(unittest.TestCase):
def setUp(self):
self.movie = Movie("Test Movie", 5)
def test_create_movie_get_name_and_rating(self):
self.assertEqual("Test Movie", self.movie.get_name())
self.assertEqual(5, self.movie.get_rating())
示例3: loadActors
def loadActors(self, count=100):
"""function to read actors data and create a relationship between actors and movie."""
actors = self.readArtists("actor", count)
self.filePointerActors = self.fileHandleActors.tell()
objActor = Actor("", 0)
objMovie = Movie("", "", 0)
for actor in actors:
name, title, year = actor
# check if actor does not exist else create ID
if objActor.getArtistByName(name, self.actorsList) == None:
self.artistCounter += 1
actorId = self.artistCounter
newActor = Actor(actorId, name)
self.actorsList.append(newActor)
# searches the movie list to check if movies have not been already visualized
if not objMovie.doesMovieExist(title, self.moviesList) and \
objMovie.getMovieByName(title, self.moviesList) == None:
self.movieCounter += 1
movieId = self.movieCounter
movie = Movie(movieId, title, year)
self.moviesList.append(movie)
# create relation between actor and movie
relation = ArtistMovieRelation(actorId, movieId)
self.relationsList.append(relation)
示例4: loadActresses
def loadActresses(self, count=100):
"""function to read actresses data and create a relationship between actress and movie,"""
# read actresses from file
actresses = self.readArtists("actress", count)
self.filePointerActresses = self.fileHandleActresses.tell()
objActress = Actress("", 0)
objMovie = Movie("", "", 0)
for actress in actresses:
name, title, year = actress
actress = objActress.getArtistByName(name, self.actressesList)
# check if actress already not exist then add it
if actress == None:
self.artistCounter += 1
actressId = self.artistCounter
newActress = Actress(actressId, name)
self.actressesList.append(newActress)
else:
actressId = actress.getArtistId()
# check if movie already exists. only if the movie doesn't exist, it will create an ID and
if not objMovie.doesMovieExist(title, self.moviesList) and \
objMovie.getMovieByName(title, self.moviesList) == None:
self.movieCounter += 1
movieId = self.movieCounter
movie = Movie(movieId, title, year)
self.moviesList.append(movie)
# create relation between actor and movie
relation = ArtistMovieRelation(actressId, movieId)
self.relationsList.append(relation)
示例5: onObjectClick
def onObjectClick(self, event):
"""function to get movie details on the movie when clicked."""
tempMovie = Movie(2, 4, "132")
tempMovie = tempMovie.getMovieByOvalId(event.widget.find_closest(event.x, event.y)[0], self.moviesList)
# get id's of the artists starring in this movie
artistmovierelation = ArtistMovieRelation(0,0)
artistStarring = artistmovierelation.getArtistsByMovieId(tempMovie.getMovieId(), self.relationsList)
tempActor = Actor("","")
tempActress = Actress("","")
# fetches the name of the actor or actress. finds out whether it originated from tbe actor or actress class.
artistsStartingNames = []
for artistId in artistStarring:
actor = tempActor.getArtistByid(artistId, self.actorsList)
if actor != None:
artistsStartingNames.append(actor.getArtistName())
else:
actress = tempActress.getArtistByid(artistId, self.actressesList)
if actress != None:
artistsStartingNames.append(actress.getArtistName())
# labels to show the film details
self.movieDetailsVar.set('Title of the Film : ' + tempMovie.getMovieTitle() + "\n" + "\n"
"Year Film Released : " + tempMovie.getMovieYear() + "\n"+ "\n"
"Actor/Actress Name : " + ", ".join(artistsStartingNames))
示例6: testGoingWithLotsOfPeopleOnThursday
def testGoingWithLotsOfPeopleOnThursday(self):
m = Movie(110, "Thursday", True, True)
for i in range(30):
m.addTicket(20+i,True)
price = m.finishPurchase()
self.assertEquals(price,30 * 9)
示例7: TestMovieClass
class TestMovieClass(unittest.TestCase):
def setUp(self):
self.m = Movie("Best.Movie.Ever.", 2014, 10)
def test_get_movie_title(self):
self.assertEqual("Best.Movie.Ever.", self.m.get_title())
def test_get_movie_year(self):
self.assertEqual(2014, self.m.get_year())
def test_get_movie_rating(self):
self.assertEqual(10, self.m.get_rating())
@unittest.skip("This works but no point in generating extra movies.")
def test_save_movie(self):
self.assertTrue(self.m.save())
示例8: getMovieInfoByTMDB_ID
def getMovieInfoByTMDB_ID(self, tmdb_id=''):
self.domain = 'movie'
self.action = 'getInfo'
if tmdb_id:
self.tmdb_id = tmdb_id
try:
movie_list = Movie.select(Movie.q.tmdb_id==self.tmdb_id)
if movie_list.count() == 1:
oMovie = movie_list[0]
elif movie_list.count() == 0:
raise SQLObjectNotFound
else:
raise AttributeError
except SQLObjectNotFound:
self.url = "%s%s" % (self.urls.generateURL(self.domain, self.action), self.tmdb_id)
self.movie_info = self._getResponse(self.url)
oMovie = Movie(tmdb_id = self._getKey('id', 0),
imdb_id = self._getKey('imdb_id', ''),
title = self._getKey('name', ''),
year = int(self._getYearFromDate(self._getKey('released', ''))),
genre = self._getPrimaryGenre(self._getKey('genres', [])),
mpaa = Movie.ratings.index(self._getKey('certification', 'NR')),
director = self._getDirector(self._getKey('cast', [])),
actors = self._getPrimaryActors(self._getKey('cast', [])),
description = self._getKey('overview', ''),
length = int(self._getKey('runtime', 0)),
poster_URL = self._getPosterURL(self._getKey('posters', '')),
)
return oMovie
示例9: _loadFactory
def _loadFactory(self):
if len(self._plugins) <= 0:
return
self._factory = fact.Factory(Movie.getTypeName())
for plug in self._plugins:
self._factory.addModule(plug)
示例10: TestMovie
class TestMovie(unittest.TestCase):
"""Tests for movie objects"""
def setUp(self):
self.movie = Movie('../test.mkv')
def test_get_extension(self):
self.assertEqual('.mkv', self.movie.get_extension())
def test_get_filename(self):
self.assertEqual('test', self.movie.get_filename())
def test_get_title(self):
self.assertEqual(None, self.movie.get_title())
def test_get_duration(self):
self.assertEqual('0:21:37', self.movie.get_duration())
示例11: load_movies
def load_movies(self):
self.cursor.execute("SELECT * FROM movies")
unparsed_movies = self.cursor.fetchall()
movies = {}
if unparsed_movies:
for unparsed_movie in unparsed_movies:
#get info from database
movie_id = unparsed_movie[0]
title = unparsed_movie[1]
year = unparsed_movie[2]
rating = unparsed_movie[3]
#create a new Movie object and add it to {movie_id: Movie}
movie = Movie(title, year, rating)
movie.cast = self.get_actors_in_movie(int(movie_id))
movies[movie_id] = movie
return movies
示例12: get_top_movies
def get_top_movies(self, top_x, min_ratings):
movie_rows_list = Movie.read_movie_file()
movie_list_with_min_ratings = []
for movie in movie_rows_list:
movie_id = movie[0]
movie_name = movie[1]
ratings_list = self.get_movie_rating_list(movie_id)
# print("movie_id", movie_id)
# print("ratings", ratings_list)
if len(ratings_list) >= min_ratings:
movie_avg_tup = (movie_id, movie_name, self.get_avg_rating(movie_id))
movie_list_with_min_ratings.append(movie_avg_tup)
sorted_list = sorted(movie_list_with_min_ratings, key = lambda x: x[2])
reversed_list = list(reversed(sorted_list))
# print(sorted_list)
# print(reversed_list)
top_x_list = reversed_list[:top_x]
#print(top_x_list)
return top_x_list
示例13: __init__
def __init__(self, movie_name):
super(Controller, self).__init__()
self.session = login()
self.movie_name = movie_name
self.movie = Movie(self.movie_name, self.session)
#self.url = 'http://s.weibo.com/weibo/'
self.url = 'http://s.weibo.com/wb/'
self.page_count = 0
示例14: find_movie
def find_movie(self,user_action):
self.header_output("Finding....")
print "\n Example: find iron or find Iron Man 3 \n"
movies = Movie.read_movies_from_file()
if user_action != []:
arg = user_action.pop(0)
found = [x for x in movies if self.search(x,arg)]
self.movie_table_output(found)
示例15: Controller
class Controller(object):
"""docstring for Controller"""
def __init__(self, movie_name):
super(Controller, self).__init__()
self.session = login()
self.movie_name = movie_name
self.movie = Movie(self.movie_name, self.session)
def start(self):
start_time = datetime.datetime.strptime(START_TIME, '%Y-%m-%d-%H')
end_time = datetime.datetime.strptime(END_TIME, '%Y-%m-%d-%H')
if start_time < end_time:
while True:
time.sleep(3)
cursor_time = start_time + datetime.timedelta(hours=1)
timescope = datetime.datetime.strftime(start_time, '%Y-%m-%d-%H') +':' + datetime.datetime.strftime(cursor_time, '%Y-%m-%d-%H')
url = 'http://s.weibo.com/weibo/'+ quote(self.movie_name) +'×cope=custom:'+ quote(timescope)
response = self.session.get(url)
count = self.get_page_count(response.content)
self.handle_one_page(url, count, self.movie.id)
start_time = cursor_time
if start_time > end_time:
break
else:
print 'ERROR:Start time must early than end time!'
def get_page_count(self, content):
max_count = 0
result = re.findall(r'&page=\d+', content)
for index in result:
info = index.split('=')
if int(info[1]) > max_count:
max_count = int(info[1])
print 'max_page:', max_count
return max_count
def handle_one_page(self, url_head, page_count, movie_id):
for i in xrange(1, page_count + 1):
page = str(i)
url = url_head +"&page=" + page
response = self.session.get(url)
self.movie.decode_content(response.content, movie_id)
print "现在是第%s页" % page
time.sleep(3)