Add the option to excluded movies available on local drive
This commit is contained in:
@ -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
|
||||
)
|
||||
|
@ -62,15 +62,16 @@ Enjoy!
|
||||
Documentation
|
||||
---
|
||||
```shell
|
||||
usage: FreeboxMoviePlanner.py [-h] [-d] [-l] [-e EXCLUDE]
|
||||
usage: FreeboxMoviePlanner.py [-h] [-d] [-l] [-e EXCLUDE] [-x EXCLUDE_DIRECTORY]
|
||||
|
||||
Schedule movie recordings on your Freebox
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-d, --day Search movies for current day only instead of a full
|
||||
week
|
||||
-d, --day Search movies for current day only instead of a full week
|
||||
-l, --log Display more log messages
|
||||
-e EXCLUDE, --exclude EXCLUDE
|
||||
Exclude the following Channel
|
||||
-x EXCLUDE_DIRECTORY, --exclude-directory EXCLUDE_DIRECTORY
|
||||
Do not display movies available in the following directory. This will prevent you from recording the same movie multiple times.
|
||||
```
|
||||
|
Reference in New Issue
Block a user