Created
June 19, 2022 16:45
-
-
Save it-is-wednesday/e09e1d41bf6aaf13b1d432800b43c0cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import webbrowser | |
from argparse import ArgumentParser | |
from typing import List | |
URL = str | |
LOCATIONS = [ | |
"afghanistan", | |
"algeria", | |
"bahrain", | |
"bangladesh", | |
"burkina-faso", | |
"comoros", | |
"djibouti", | |
"egypt", | |
"iran", | |
"iraq", | |
"jordan", | |
"kuwait", | |
"libya", | |
"malaysia", | |
"maldives", | |
"mauritania", | |
"morocco", | |
"palestine", | |
"qatar", | |
"saudi-arabia", | |
"somalia", | |
"sudan", | |
"syrian-arab-republic", | |
"tunisia", | |
"turkey", | |
"united-arab-emirates", | |
"yemen", | |
] | |
LANGUAGES = [ | |
"ar", # arabic | |
"fa", # farsi | |
"ku", # kurdish | |
"tr", # turkish | |
"wo", # wolof | |
] | |
def genre_charts_url(genres: str, timeframe: str) -> URL: | |
return f"https://rateyourmusic.com/charts/top/album/{timeframe}/ge:{genres}" | |
def location_charts_url(locations: List[str]) -> URL: | |
return f"/loc:{','.join(locations)}" | |
def language_charts_url(languages: List[str]) -> URL: | |
return f"/l:{','.join(languages)}" | |
def main(genres: str, timeframe: str) -> None: | |
base = genre_charts_url(genres, timeframe) | |
webbrowser.open(f"{base}/{location_charts_url(LOCATIONS)}") | |
webbrowser.open(f"{base}/{language_charts_url(LANGUAGES)}") | |
if __name__ == "__main__": | |
parser = ArgumentParser() | |
parser.add_argument("genres") | |
parser.add_argument("--timeframe", default="all-time") | |
args = parser.parse_args() | |
main(args.genres, args.timeframe) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment