Interactive movie selection

This commit is contained in:
2019-10-06 23:08:44 +02:00
parent fca1cb2c5a
commit 6587cb2457

View File

@ -28,6 +28,7 @@ class Movie:
self.good = False self.good = False
self.tmdb_id = '' self.tmdb_id = ''
self.url = '' self.url = ''
self.user_selected = False
def __str__(self): def __str__(self):
return '{}: {} - {} ({})\n TMDB: {} - {}\n @ {}\n {}'.format( return '{}: {} - {} ({})\n TMDB: {} - {}\n @ {}\n {}'.format(
@ -42,7 +43,12 @@ class Movie:
) )
def __repr__(self): def __repr__(self):
return 'Movie <{}({})>'.format(self.title, self.rating) return 'Movie <{} ({} :: {} :: {})>'.format(
self.title,
self.day,
self.channel,
self.rating
)
class TVGuideScraper: class TVGuideScraper:
@ -112,8 +118,16 @@ class FreeboxMoviePlanner:
return result return result
def printAllMovies(self): def printAllMovies(self):
for movie in self.movies:
print('{!r}'.format(movie))
print()
def askForUserSelection(self):
for movie in self.movies: for movie in self.movies:
print(movie) print(movie)
reply = input("Interested? (y/N)")
if reply.upper() == "Y":
movie.user_selected = True
print() print()
def findMoviesOnTMDB(self): def findMoviesOnTMDB(self):
@ -141,6 +155,9 @@ class FreeboxMoviePlanner:
m for m in self.movies if m.channel not in paid_channels m for m in self.movies if m.channel not in paid_channels
] ]
def excludeNotSelected(self):
self.movies = [m for m in self.movies if m.user_selected]
def _findMovieOnTMDB(self, movie): def _findMovieOnTMDB(self, movie):
logging.info("Searching for '{}' on TMDB".format(movie)) logging.info("Searching for '{}' on TMDB".format(movie))
search = tmdbsimple.Search() search = tmdbsimple.Search()
@ -164,4 +181,7 @@ if __name__ == '__main__':
fmp.findMoviesOnTMDB() fmp.findMoviesOnTMDB()
fmp.excludeBadRatings() fmp.excludeBadRatings()
fmp.excludePaidChannels() fmp.excludePaidChannels()
fmp.askForUserSelection()
fmp.excludeNotSelected()
print('\n====== Selected ======\n')
fmp.printAllMovies() fmp.printAllMovies()