Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI

on:
push:
branches: [main]
pull_request:

permissions:
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ Recherchez votre cinéma et relevez son identifiant dans l’URL. Dans cet exemp

![Identifiant du cinéma](snapshot_theater_id.png)

![Capture terminal](capture.svg)
![Capture terminal](demo.gif)

#### Aide

```bash
seances.py --help
Usage: seances.py [OPTIONS] ID_CINEMA
seances --help
Usage: seances [OPTIONS] ID_CINEMA

Les séances de votre cinéma dans le terminal, avec ID_CINEMA : identifiant
du cinéma sur Allociné, ex: C0159 pour l’UGC Ciné Cité Les Halles. Se
Expand All @@ -53,7 +53,7 @@ Options:
#### Utilisation simple

```bash
seances.py P2235
seances P2235

27/12/2018
┌──────────────────────────────────────────────────────────┬──────┬───────┬───────┬───────┬───────┐
Expand All @@ -67,7 +67,7 @@ seances.py P2235
#### Pour demain, avec des interlignes

```bash
seances.py P2235 -j+1 --entrelignes
seances P2235 -j+1 --entrelignes

28/12/2018
┌────────────────────────────────────────────────────┬──────┬───────┬───────┬───────┐
Expand All @@ -82,13 +82,13 @@ seances.py P2235 -j+1 --entrelignes
#### Pour une date précise

```bash
seances.py P2235 --jour 29/12/2018
seances P2235 --jour 29/12/2018
```

#### Pour toute la semaine

```bash
seances.py P2235 --semaine
seances P2235 --semaine
```

## Utilisation de la bibliothèque
Expand Down Expand Up @@ -126,7 +126,7 @@ Le cache est activé par défaut. Les réponses sont enregistrées dans le répe
Videz le cache en ligne de commande (aucun identifiant de cinéma n’est nécessaire) :

```bash
seances.py --clear-cache
seances --clear-cache
```

## Développement
Expand Down Expand Up @@ -176,6 +176,7 @@ publier. Le workflow rejette les distributions dont la version ne correspond pas
wheel et de la distribution source avant leur publication :

```bash
git tag -a 0.0.13 -m 0.0.13
git push origin 0.0.13
VERSION=0.0.13
git tag -a ${VERSION} -m ${VERSION}
git push origin ${VERSION}
```
32 changes: 13 additions & 19 deletions allocine/cli.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""Command-line interface for Allociné showtimes."""

from datetime import date, datetime, timedelta
from io import StringIO

import click
from prettytable import ALL, FRAME, UNICODE, PrettyTable
from rich import box
from rich.console import Console
from rich.table import Table

from allocine.client import Allocine
from allocine.schedules import get_showtimes_of_a_day
Expand Down Expand Up @@ -131,26 +134,17 @@ def get_showtime_table(showtimes, entrelignes, jour):
retour += "Aucune séance"

else:
table = PrettyTable()
table.set_style(UNICODE)
table.header = False
field_names = extract_field_names(seances)
table = Table(box=box.SQUARE, show_header=False, show_lines=entrelignes)
for field_name in field_names:
table.add_column(justify="left" if field_name == "*1_film" else "center", no_wrap=True)

if entrelignes is True:
table.hrules = ALL
else:
table.hrules = FRAME

table.field_names = extract_field_names(seances)

for seances_film in seances:
row = []
for field_name in table.field_names:
row.append(seances_film.get(field_name, ""))
table.add_row(row)
for seances_film in sorted(seances, key=lambda seance: seance["*1_film"]):
table.add_row(*(seances_film.get(field_name, "") for field_name in field_names))

table.align["*1_film"] = "l"
table.sortby = "*1_film"
retour += str(table)
output = StringIO()
Console(file=output, color_system=None, width=1000, markup=False).print(table)
retour += output.getvalue().rstrip("\n")

return retour

Expand Down
1 change: 0 additions & 1 deletion capture.svg

This file was deleted.

Binary file added demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading