from enum import Enum
from django.db.models import TextChoices

class MediaType(TextChoices):
    """Enum mapping a media model type to a string"""

    VIDEO = "Video", "Video"
    TRACK = "Track", "Track"
    PODCAST_EPISODE = "PodcastEpisode", "Podcast episode"
    SPORT_EVENT = "SportEvent", "Sport event"
    BOOK = "Book", "Book"
    PAPER = "Paper", "Paper"
    VIDEO_GAME = "VideoGame", "Video game"
    BOARD_GAME = "BoardGame", "Board game"
    GEO_LOCATION = "GeoLocation", "GeoLocation"
    TRAIL = "Trail", "Trail"
    BEER = "Beer", "Beer"
    PUZZLE = "Puzzle", "Puzzle"
    FOOD = "Food", "Food"
    TASK = "Task", "Task"
    WEBPAGE = "WebPage", "Web Page"
    LIFE_EVENT = "LifeEvent", "Life event"
    MOOD = "Mood", "Mood"
    BRICKSET = "BrickSet", "Brick set"

    @classmethod
    def list(cls):
        return list(map(lambda c: c.value, cls))

JELLYFIN_VIDEO_ITEM_TYPES = ["Episode", "Movie"]
JELLYFIN_AUDIO_ITEM_TYPES = ["Audio"]

LONG_PLAY_MEDIA = {
    "videogames": "VideoGame",
    "books": "Book",
    "bricksets": "BrickSet",
    "tasks": "Task",
}

PLAY_AGAIN_MEDIA = {
    "videogames": "VideoGame",
    "books": "Book",
    "boardgames": "BoardGame",
    "moods": "Mood",
    "bricksets": "BrickSet",
    "trails": "Trail",
    "beers": "Beer",
    "foods": "Food",
    "locations": "GeoLocation",
    "videos": "Video",
}

MEDIA_END_PADDING_SECONDS = {
    "Video": 3600,  # 60 min
}

TODOIST_TASK_URL = "https://app.todoist.com/app/task/{id}"

SCROBBLE_CONTENT_URLS = {
    "-i": ["https://www.imdb.com/title/", "https://www.youtube.com/watch?v="],
    "-s": ["https://www.thesportsdb.com/event/"],
    "-g": ["https://boardgamegeek.com/boardgame/"],
    "-u": ["https://untappd.com/"],
    "-b": ["https://www.amazon.com/"],
    "-t": ["https://app.todoist.com/app/task/{id}"],
    "-p": ["https://www.ipdb.plus/IPDb/puzzle.php?id="],
    "-l": ["https://brickset.com/sets/"],
    "-c": ["https://readcomicsonline.ru"],
}

EXCLUDE_FROM_NOW_PLAYING = ("GeoLocation",)

MANUAL_SCROBBLE_FNS = {
    "-v": "manual_scrobble_video_game",
    "-b": "manual_scrobble_book",
    "-s": "manual_scrobble_event",
    "-i": "manual_scrobble_video",
    "-g": "manual_scrobble_board_game",
    "-u": "manual_scrobble_beer",
    "-w": "manual_scrobble_webpage",
    "-t": "manual_scrobble_task",
    "-p": "manual_scrobble_puzzle",
    "-l": "manual_scrobble_brickset",
    "-c": "manual_scrobble_book",
}


class AsTsvColumn(Enum):
    ARTIST_NAME = 0
    ALBUM_NAME = 1
    TRACK_NAME = 2
    TRACK_NUMBER = 3
    RUN_TIME_SECONDS = 4
    COMPLETE = 5
    TIMESTAMP = 6
    MB_ID = 7
