Skip to content

Commit

Permalink
rename module, black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vdmkenny committed May 29, 2024
1 parent 1a52335 commit 4495c9a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ These options can be combined.

```bash
# Show movie schedules for today
python cine-aalst.py -d today
python cine_aalst.py -d today

# Show movie schedules for tomorrow
python cine-aalst.py -d tomorrow
python cine_aalst.py -d tomorrow

# Show movie schedules for a specific date (Schedules are available for the next 7 days or so)
python cine-aalst.py -d 2024-04-12
python cine_aalst.py -d 2024-04-12

# Search for a movie by title (Partial matches are also supported)
python cine-aalst.py -m "Kung Fu Panda"
python cine_aalst.py -m "Kung Fu Panda"

# Search for a specific movie on a specific date
python cine-aalst.py -d 2024-04-12 -m "Kung Fu Panda"
python cine_aalst.py -d 2024-04-12 -m "Kung Fu Panda"

```
28 changes: 7 additions & 21 deletions cine-aalst.py → cine_aalst.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,12 @@ def print_movie(movie, schedules, cinemas, screens):
print(
f" - \033[1mPoster:\033[0m \x1B]8;;https://cine-aalst.be{movie['poster']}\x1B\\Link\x1B]8;;\x1B\\"
)
print(
f" - \033[1mTrailer:\033[0m \x1B]8;;https:{movie['trailer']}\x1B\\Link\x1B]8;;\x1B\\")
print(f" - \033[1mTrailer:\033[0m \x1B]8;;https:{movie['trailer']}\x1B\\Link\x1B]8;;\x1B\\")
print(f" - \033[1mRuntime:\033[0m {movie['runtime']} minutes")
if movie["nation"] is not None:
print(f" - \033[1mNation:\033[0m {movie['nation']}")
release_date = datetime.fromisoformat(movie["release"].split("+")[0])
print(
f" - \033[1mRelease Date:\033[0m {release_date.strftime('%Y-%m-%d')}")
print(f" - \033[1mRelease Date:\033[0m {release_date.strftime('%Y-%m-%d')}")
print(" - \033[1mSchedules:\033[0m")
for schedule in schedules:
start_time = datetime.fromisoformat(schedule["start"].split("+")[0])
Expand Down Expand Up @@ -137,8 +135,7 @@ def print_movies_by_date(movies, schedules, cinemas, screens, target_date):


def print_movies_by_title(search_query, movies, schedules, cinemas, screens):
matching_movies = [
movie for movie in movies if search_query.lower() in movie["title"].lower()]
matching_movies = [movie for movie in movies if search_query.lower() in movie["title"].lower()]
if matching_movies:
print(f"\033[1mMovies matching '{search_query}':\033[0m")
for movie in matching_movies:
Expand All @@ -160,12 +157,11 @@ def parse_date(date_str):
except ValueError as exc:
raise argparse.ArgumentTypeError(
"Invalid date format. Please use YYYY-MM-DD, 'today' or 'tomorrow'."
) from exc
) from exc


def main():
parser = argparse.ArgumentParser(
description="Get movie schedules for Cine Aalst.")
parser = argparse.ArgumentParser(description="Get movie schedules for Cine Aalst.")
parser.add_argument(
"-d",
"--date",
Expand All @@ -188,12 +184,7 @@ def main():
filtered_schedules = filter_schedules_by_date(schedules, args.date)
else:
filtered_schedules = schedules # All schedules
print_movies_by_title(
args.movie,
movies,
filtered_schedules,
cinemas,
screens)
print_movies_by_title(args.movie, movies, filtered_schedules, cinemas, screens)
else:
if args.date == "today":
args.date = datetime.today().date()
Expand All @@ -202,12 +193,7 @@ def main():
filtered_schedules = filter_schedules_by_date(schedules, args.date)
else:
filtered_schedules = schedules # All schedules
print_movies_by_date(
movies,
filtered_schedules,
cinemas,
screens,
args.date)
print_movies_by_date(movies, filtered_schedules, cinemas, screens, args.date)


if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
python_requires=">=3.6",
)

0 comments on commit 4495c9a

Please sign in to comment.