from enum import Enum

from django.db import models

JELLYFIN_VIDEO_ITEM_TYPES = ["Episode", "Movie"]


class Visibility(models.TextChoices):
    PUBLIC = "public", "Public"
    SHARED = "shared", "Shared"
    PRIVATE = "private", "Private"


JELLYFIN_AUDIO_ITEM_TYPES = ["Audio"]

# Tags applied to scrobbles created from webhook POST data whose media has
# not been enriched yet. Enrichment happens asynchronously; success moves the
# scrobble to WEBHOOK_ENRICHED_TAG, failure to ENRICHMENT_FAILED_TAG.
WEBHOOK_METADATA_ONLY_TAG = "webhook-metadata-only"
WEBHOOK_ENRICHED_TAG = "webhook-enriched"
ENRICHMENT_FAILED_TAG = "enrichment-failed"

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

# Media types that should just be finished if they go over time
AUTO_FINISH_MEDIA = {
    "webpages": "WebPage",
    "tracks": "Track",
    "videos": "Video",
    "moods": "Mood",
    "drinks": "Drink",
}

PLAY_AGAIN_MEDIA = {
    "videos": "Video",
    "music": "Track",
    "podcasts": "PodcastEpisode",
    "sports": "SportEvent",
    "books": "Book",
    "videogames": "VideoGame",
    "boardgames": "BoardGame",
    "locations": "GeoLocation",
    "trails": "Trail",
    "drinks": "Beer",
    "drinks": "Wine",
    "drinks": "Coffee",
    "drinks": "Drink",
    "puzzles": "Puzzle",
    "foods": "Food",
    "tasks": "Task",
    "webpages": "WebPage",
    "lifeevents": "LifeEvent",
    "moods": "Mood",
    "bricksets": "BrickSet",
    "channels": "Channel",
    "birds": "BirdingLocation",
    "discgolf": "DiscGolfCourse",
    "nature": "SpeciesObservation",
    "workouts": "Workout",
}

DRINK_MODELS = ["Beer", "Wine", "Coffee", "Drink"]

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/"],
    "-wi": [],
    "-co": ["https://roastdb.com/"],
    "-b": ["https://www.amazon.com/"],
    "-t": ["https://app.todoist.com/app/task/{id}"],
    "-p": ["https://www.ipdb.plus/IPDb/puzzle.php?id="],
    "-pp": ["https://doi.org/"],
    "-l": ["https://brickset.com/sets/"],
    "-c": ["https://readcomicsonline.ru"],
    "-h": ["https://www.twitch.tv/"],
}

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",
    "-wi": "manual_scrobble_wine",
    "-co": "manual_scrobble_coffee",
    "-w": "manual_scrobble_webpage",
    "-t": "manual_scrobble_task",
    "-p": "manual_scrobble_puzzle",
    "-l": "manual_scrobble_brickset",
    "-c": "manual_scrobble_book",
    "-f": "manual_scrobble_food",
    "-d": "manual_scrobble_drink",
    "-h": "manual_scrobble_twitch_channel",
    "-dg": "manual_scrobble_discgolf",
    "-pp": "manual_scrobble_paper",
}


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
