commit 6ef7f3e94f47cac13f147ff1c3a434bac71a37d8 Author: djib Date: Mon Sep 23 22:29:13 2019 +0200 Initial commit - Displays movies on a specific day diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2bf2de --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.project +/.pydevproject diff --git a/FreeboxMoviePlanner.py b/FreeboxMoviePlanner.py new file mode 100644 index 0000000..0c6eda9 --- /dev/null +++ b/FreeboxMoviePlanner.py @@ -0,0 +1,30 @@ +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() \ No newline at end of file diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..219b717 --- /dev/null +++ b/Pipfile @@ -0,0 +1,11 @@ +[[source]] +url = "https://pypi.python.org/simple" +verify_ssl = true +name = "pypi" + +[packages] + +[dev-packages] + +[requires] +python_version = "3.7"