Skip to content

Instantly share code, notes, and snippets.

@jabbalaci
Created June 19, 2019 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jabbalaci/d8e051bae3e670dac41c52a9e6549d97 to your computer and use it in GitHub Desktop.
Save jabbalaci/d8e051bae3e670dac41c52a9e6549d97 to your computer and use it in GitHub Desktop.
Apolló mozi, Debrecen, aktuális havi moziműsor
#!/usr/bin/env python3
import sys
from datetime import datetime
import webbrowser
MONTHS = {
1: 'januar',
2: 'februar',
3: 'marcius',
4: 'aprilis',
5: 'majus',
6: 'junius',
7: 'julius',
8: 'augusztus',
9: 'szeptember',
10: 'oktober',
11: 'november',
12: 'december',
}
url_template = "http://apollomozi.hu/{month}i-mozimusor-2"
def main(offset):
current_month = int(datetime.now().strftime('%m'))
current_month += offset
if current_month == 0:
current_month = 12
url = url_template.format(month=MONTHS[current_month])
print("#", url)
webbrowser.open_new_tab(url)
##############################################################################
if __name__ == "__main__":
number_of_params = len(sys.argv[1:])
if number_of_params == 0:
main(offset=0)
elif number_of_params == 1:
if sys.argv[1] != "-1":
print("Error: if you provide a parameter, then it must be '-1'!", file=sys.stderr)
exit(1)
# else
main(offset=-1)
else:
print("Error: there can be only one parameter!", file=sys.stderr)
exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment