예제 #1
0
	def traktLoadMovies(self):
		self.updateProgress(5, line2=utilities.getString(1462))

		Debug("[Movies Sync] Getting movie collection from trakt.tv")
		movies = self.traktapi.getMovieLibrary()
		if not isinstance(movies, list):
			Debug("[Movies Sync] Invalid trakt.tv movie list, possible error getting data from trakt, aborting trakt.tv collection update.")
			return False

		self.updateProgress(6, line2=utilities.getString(1463))

		Debug("[Movies Sync] Getting seen movies from trakt.tv")
		watched_movies = self.traktapi.getWatchedMovieLibrary()
		if not isinstance(watched_movies, list):
			Debug("[Movies Sync] Invalid trakt.tv movie seen list, possible error getting data from trakt, aborting trakt.tv watched update.")
			return False

		self.updateProgress(8, line2=utilities.getString(1464))

		i = 0
		x = float(len(movies))
		# reformat movie arrays
		for movie in movies:
			movie['plays'] = 0
			movie['in_collection'] = True
			if movie['imdb_id'] is None:
				movie['imdb_id'] = ""
			if movie['tmdb_id'] is None:
				movie['tmdb_id'] = ""

			i = i + 1
			y = ((i / x) * 6) + 8
			self.updateProgress(int(y), line2=utilities.getString(1465))

		i = 0
		x = float(len(watched_movies))
		for movie in watched_movies:
			if movie['imdb_id'] is None:
				movie['imdb_id'] = ""
			if movie['tmdb_id'] is None:
				movie['tmdb_id'] = "" 
			else:
				movie['tmdb_id'] = unicode(movie['tmdb_id'])
			m = utilities.findMovie(movie, movies)
			if m:
				m['plays'] = movie['plays']
			else:
				movie['in_collection'] = False
				movies.append(movie)

			i = i + 1
			y = ((i / x) * 6) + 14
			self.updateProgress(int(y), line2=utilities.getString(1465))

		self.updateProgress(20, line2=utilities.getString(1466))

		return movies
예제 #2
0
	def compareMovies(self, movies_col1, movies_col2, watched=False, restrict=False):
		movies = []
		for movie_col1 in movies_col1:
			movie_col2 = utilities.findMovie(movie_col1, movies_col2)
			if movie_col2:
				if watched:
					if (movie_col2['plays'] == 0) and (movie_col1['plays'] > movie_col2['plays']):
						if 'movieid' not in movie_col1:
							movie_col1['movieid'] = movie_col2['movieid']
						movies.append(movie_col1)
				else:
					if 'in_collection' in movie_col2 and not movie_col2['in_collection']:
						movies.append(movie_col1)
			else:
				if not restrict:
					if 'in_collection' in movie_col1 and movie_col1['in_collection']:
						if watched and (movie_col1['plays'] > 0):
							movies.append(movie_col1)
						elif not watched:
							movies.append(movie_col1)
		return movies