A Python script to help you select the movies you want to record with your Freebox
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.0 KiB

import requests
from bs4 import BeautifulSoup
class FreeboxMoviePlanner:
TV_GUIDE_URL = 'https://www.programme-television.org/{}?bouquet=tnt'
@staticmethod
def _tag_is_film(tag):
return (
tag.has_attr('data-nature')
and
tag['data-nature']=='films-telefilms'
)
def getMovies(self, day=''):
r = requests.get(self.TV_GUIDE_URL.format(day))
r.raise_for_status()
html = BeautifulSoup(r.text, 'html.parser')
for channel in html.select('.bloc_cnt'):
if len(channel.select('em')):
for movie in channel.find_all(FreeboxMoviePlanner._tag_is_film):
print("{} - {} ({})".format(
movie.select('.texte_titre a')[0]['title'],
movie.select('.texte_cat a')[0].string,
channel.select('em')[0].string.replace('Programme ','')
))
if __name__ == '__main__':
fmp = FreeboxMoviePlanner()
fmp.getMovies()