|
|
|
@ -7,6 +7,7 @@ import argparse |
|
|
|
|
import datetime |
|
|
|
|
import json |
|
|
|
|
import logging |
|
|
|
|
import os |
|
|
|
|
import re |
|
|
|
|
import requests |
|
|
|
|
import socket |
|
|
|
@ -135,7 +136,7 @@ class TVGuideScraper: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FreeboxMoviePlanner: |
|
|
|
|
def __init__(self, movies, excluded_channels=[]): |
|
|
|
|
def __init__(self, movies, excluded_channels=[], excluded_directory=False): |
|
|
|
|
logging.debug('Opening config file: config.json') |
|
|
|
|
with open('config.json') as config_file: |
|
|
|
|
self.config = json.load(config_file) |
|
|
|
@ -143,6 +144,7 @@ class FreeboxMoviePlanner: |
|
|
|
|
self.createAuthenticationToken() |
|
|
|
|
tmdbsimple.API_KEY = self.config['tmdb-api'] |
|
|
|
|
self.movies = movies |
|
|
|
|
self.excluded_directory = excluded_directory |
|
|
|
|
|
|
|
|
|
logging.info('Opening Freebox session') |
|
|
|
|
self.freebox = Fbx(nomdns=True) |
|
|
|
@ -155,6 +157,8 @@ class FreeboxMoviePlanner: |
|
|
|
|
self.excludeTelevisionFilm() |
|
|
|
|
self.findMoviesOnTMDB() |
|
|
|
|
self.excludeBadRatings() |
|
|
|
|
if self.excluded_directory: |
|
|
|
|
self.excludeLocalMovies() |
|
|
|
|
self.askForUserSelection() |
|
|
|
|
self.excludeNotSelected() |
|
|
|
|
self.programMovies() |
|
|
|
@ -272,6 +276,15 @@ class FreeboxMoviePlanner: |
|
|
|
|
m for m in self.movies if not m.genre.startswith("Téléfilm") |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
def excludeLocalMovies(self): |
|
|
|
|
(_, _, filenames) = next(os.walk('.')) |
|
|
|
|
logging.info('Dropping movies already recorded: {}'.format( |
|
|
|
|
[ m for m in self.movies if m.title+'.m2ts' in filenames ] |
|
|
|
|
)) |
|
|
|
|
self.movies = [ |
|
|
|
|
m for m in self.movies if not m.title+'.m2ts' in filenames |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
def excludeNotSelected(self): |
|
|
|
|
self.movies = [m for m in self.movies if m.user_selected] |
|
|
|
|
|
|
|
|
@ -330,6 +343,13 @@ if __name__ == '__main__': |
|
|
|
|
default=[], |
|
|
|
|
help='Exclude the following Channel' |
|
|
|
|
) |
|
|
|
|
parser.add_argument( |
|
|
|
|
'-x', '--exclude-directory', |
|
|
|
|
nargs=1, |
|
|
|
|
help='''Do not display movies available in the following directory. |
|
|
|
|
This will prevent you from recording the same movie multiple |
|
|
|
|
times.''' |
|
|
|
|
) |
|
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
|
|
print("Working the magic, please wait…") |
|
|
|
@ -339,4 +359,8 @@ if __name__ == '__main__': |
|
|
|
|
movies = TVGuideScraper._getMovies() |
|
|
|
|
else: |
|
|
|
|
movies = TVGuideScraper.findAllMovies() |
|
|
|
|
fmp = FreeboxMoviePlanner(movies, excluded_channels=args.exclude) |
|
|
|
|
fmp = FreeboxMoviePlanner( |
|
|
|
|
movies, |
|
|
|
|
excluded_channels=args.exclude, |
|
|
|
|
excluded_directory=args.exclude_directory |
|
|
|
|
) |
|
|
|
|