Initial commit - Displays movies on a specific day
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/.project
|
||||||
|
/.pydevproject
|
30
FreeboxMoviePlanner.py
Normal file
30
FreeboxMoviePlanner.py
Normal file
@ -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()
|
Reference in New Issue
Block a user