diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7204bc..254fe27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,7 @@ name: CI on: push: + branches: [main] pull_request: permissions: diff --git a/README.md b/README.md index e5dc1e5..f568c01 100644 --- a/README.md +++ b/README.md @@ -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 @@ -53,7 +53,7 @@ Options: #### Utilisation simple ```bash -seances.py P2235 +seances P2235 27/12/2018 ┌──────────────────────────────────────────────────────────┬──────┬───────┬───────┬───────┬───────┐ @@ -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 ┌────────────────────────────────────────────────────┬──────┬───────┬───────┬───────┐ @@ -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 @@ -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 @@ -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} ``` diff --git a/allocine/cli.py b/allocine/cli.py index c8804c3..338f13b 100644 --- a/allocine/cli.py +++ b/allocine/cli.py @@ -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 @@ -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 diff --git a/capture.svg b/capture.svg deleted file mode 100644 index af644ca..0000000 --- a/capture.svg +++ /dev/null @@ -1 +0,0 @@ -bash-3.2$seances.pyP0645GaumontToulouseLabegeIMAX,le27/12/2018┌─────────────────────────────────────────────────────────────┬──────┬───────┬───────┐│AStarIsBorn(VOST)-02h16│4.5*││22:15││Aquaman(VF3D,Salle4DX)-02h24│4.0*││22:00││Astérix-LeSecretdelaPotionMagique...(VF3D)-01h25│4.1*││22:15││Bumblebee(VFIMAX3D)-01h54│3.8*│21:50│││Bumblebee(VF)-01h54│3.8*││22:30││Enliberté!(VF)-01h48│3.2*││22:25││L'EmpereurdeParis(VF)-01h50│3.4*││22:30││L'ExorcismedeHannahGrace(VF)-01h25│2.4*││22:45││LeGendredemavie(VF)-01h40│2.4*││22:30││LeGrandBain(VF)-01h58│4.0*│21:45│││LeRetourdeMaryPoppins(VF)-02h11│3.5*│21:45│││MortalEngines(VF)-02h08│3.4*││22:00││Secondechance(VF)-01h44│3.2*││22:45││Unfriended:DarkWeb(VF)-01h28│3.3*││22:45│└─────────────────────────────────────────────────────────────┴──────┴───────┴───────┘bash-3.2$sbash-3.2$sebash-3.2$seabash-3.2$seanbash-3.2$seances.pybash-3.2$seances.pyPbash-3.2$seances.pyP0bash-3.2$seances.pyP06bash-3.2$seances.pyP064│L'ExorcismedeHannahGracebash-3.2$bash-3.2$exit \ No newline at end of file diff --git a/demo.gif b/demo.gif new file mode 100644 index 0000000..5b447af Binary files /dev/null and b/demo.gif differ diff --git a/demo.tape b/demo.tape new file mode 100644 index 0000000..300c3d8 --- /dev/null +++ b/demo.tape @@ -0,0 +1,95 @@ +# To update demo.gif, run: +# brew install vhs +# vhs demo.tape + +# VHS documentation +# +# Output: +# Output .gif Create a GIF output at the given +# Output .mp4 Create an MP4 output at the given +# Output .webm Create a WebM output at the given +# +# Require: +# Require Ensure a program is on the $PATH to proceed +# +# Settings: +# Set FontSize Set the font size of the terminal +# Set FontFamily Set the font family of the terminal +# Set Height Set the height of the terminal +# Set Width Set the width of the terminal +# Set LetterSpacing Set the font letter spacing (tracking) +# Set LineHeight Set the font line height +# Set LoopOffset % Set the starting frame offset for the GIF loop +# Set Theme Set the theme of the terminal +# Set Padding Set the padding of the terminal +# Set Framerate Set the framerate of the recording +# Set PlaybackSpeed Set the playback speed of the recording +# Set MarginFill Set the file or color the margin will be filled with. +# Set Margin Set the size of the margin. Has no effect if MarginFill isn't set. +# Set BorderRadius Set terminal border radius, in pixels. +# Set WindowBar Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight) +# Set WindowBarSize Set window bar size, in pixels. Default is 40. +# Set TypingSpeed