Add margin before and after in settings
This commit is contained in:
@ -4,12 +4,10 @@ Simple script that extracts information from Télé 7 jours and TMDB
|
|||||||
to help choosing the movies you want to record with your Freebox
|
to help choosing the movies you want to record with your Freebox
|
||||||
|
|
||||||
Todo :
|
Todo :
|
||||||
* Scrape beginning and end time
|
|
||||||
* Schedule recordings on Freebox using the FB API
|
|
||||||
https://dev.freebox.fr/sdk/os/pvr/#pvr-programmed-records
|
|
||||||
* Add a configuration setting for beginning and end margin
|
* Add a configuration setting for beginning and end margin
|
||||||
* Display conflicts if any
|
* Display conflicts if any
|
||||||
"""
|
"""
|
||||||
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
@ -42,8 +40,6 @@ class Movie:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{}: {} - {} ({})\n TMDB: {} - {}\n @ {}\n {}'.format(
|
return '{}: {} - {} ({})\n TMDB: {} - {}\n @ {}\n {}'.format(
|
||||||
'Today' if self.day == '' else self.day,
|
'Today' if self.day == '' else self.day,
|
||||||
self.start_time,
|
|
||||||
self.end_time,
|
|
||||||
self.title,
|
self.title,
|
||||||
self.genre,
|
self.genre,
|
||||||
self.channel,
|
self.channel,
|
||||||
@ -184,9 +180,11 @@ class FreeboxMoviePlanner:
|
|||||||
def askForUserSelection(self):
|
def askForUserSelection(self):
|
||||||
for movie in self.movies:
|
for movie in self.movies:
|
||||||
print(movie)
|
print(movie)
|
||||||
reply = input("Interested? (y/N)")
|
reply = input("Interested? (y)es/(N)o/(s)kip")
|
||||||
if reply.upper() == "Y":
|
if reply.upper() == "Y":
|
||||||
movie.user_selected = True
|
movie.user_selected = True
|
||||||
|
elif reply.upper() == "S":
|
||||||
|
break
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def findMoviesOnTMDB(self):
|
def findMoviesOnTMDB(self):
|
||||||
@ -237,13 +235,17 @@ class FreeboxMoviePlanner:
|
|||||||
|
|
||||||
def programMovies(self):
|
def programMovies(self):
|
||||||
for movie in self.movies:
|
for movie in self.movies:
|
||||||
|
logging.info("Programming '{}'".format(movie))
|
||||||
data = {
|
data = {
|
||||||
'channel_uuid': self.channels[movie.channel],
|
'channel_uuid': self.channels[movie.channel],
|
||||||
'start': int(movie.start_time.timestamp()),
|
'start': int(movie.start_time.timestamp()),
|
||||||
'end': int(movie.end_time.timestamp()),
|
'end': int(movie.end_time.timestamp()),
|
||||||
'name': movie.title
|
'name': movie.title,
|
||||||
|
'margin_before': self.config['margin-before'],
|
||||||
|
'margin_after': self.config['margin-after']
|
||||||
}
|
}
|
||||||
self.freebox.Pvr.Create_a_precord(data)
|
self.freebox.Pvr.Create_a_precord(data)
|
||||||
|
print("Programmed '{}'".format(movie))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -251,5 +253,16 @@ if __name__ == '__main__':
|
|||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
format=' %(asctime)s - %(levelname)s - %(message)s'
|
format=' %(asctime)s - %(levelname)s - %(message)s'
|
||||||
)
|
)
|
||||||
fmp = FreeboxMoviePlanner(TVGuideScraper.findAllMovies())
|
parser = argparse.ArgumentParser(description='Plan movies on your Freebox')
|
||||||
# fmp = FreeboxMoviePlanner(TVGuideScraper._getMovies())
|
parser.add_argument(
|
||||||
|
'-d', '--day',
|
||||||
|
action='store_true',
|
||||||
|
help='Search for a single day ahead'
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.day:
|
||||||
|
movies = TVGuideScraper._getMovies()
|
||||||
|
else:
|
||||||
|
movies = TVGuideScraper.findAllMovies()
|
||||||
|
fmp = FreeboxMoviePlanner(movies)
|
||||||
|
@ -2,5 +2,7 @@
|
|||||||
"tmdb-api":"yourapikey",
|
"tmdb-api":"yourapikey",
|
||||||
"tmdb-language":"en-GB",
|
"tmdb-language":"en-GB",
|
||||||
"minimum-rating":6.5,
|
"minimum-rating":6.5,
|
||||||
"pyfbx-session-token":"See https://framagit.org/sun/pyfbx"
|
"pyfbx-session-token":"See https://framagit.org/sun/pyfbx",
|
||||||
|
"margin-before":5,
|
||||||
|
"margin-after":25
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user