Browse Source

Initial commit - Displays movies on a specific day

master
djib 3 years ago
commit
6ef7f3e94f
  1. 2
      .gitignore
  2. 30
      FreeboxMoviePlanner.py
  3. 11
      Pipfile

2
.gitignore

@ -0,0 +1,2 @@
/.project
/.pydevproject

30
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()

11
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"
Loading…
Cancel
Save