import os

from os.path import abspath, dirname, join

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = dirname(dirname(abspath(__file__)))

# duration of the fade out at the end of a playlist in second
FADE_OUT_DURATION = 20

# number of step during the fade out.
# At each step, the volume is reduced by the same amount until 0
FADE_OUT_STEP = 100

BO_API_URL = 'https://owlright.hashbang.fr'
API_BASIC_USERNAME = 'apimaster@owlright.fr'
API_BASIC_PASSWORD = '>Mast3r of the AP1s<'
ADMIN_TOKEN = '870ADM1N990WLRIGHT43'

# expects output like : "KeyName       : value"
SERIAL_NUMBER_READ_COMMAND = 'cat /proc/cpuinfo | grep Serial'

PLAYER_LINEIN_TO_LINEOUT_CMD = join(BASE_DIR, 'bin', 'linein_to_lineout.sh')
PLAYER_PLAYBACK_TO_LINEOUT_CMD = join(
    BASE_DIR, 'bin', 'playback_to_lineout.sh'
)
PLAYER_NOTHING_TO_LINEOUT_CMD = join(BASE_DIR, 'bin', 'nothing_to_lineout.sh')
PLAYER_SET_VOLUME = join(BASE_DIR, 'bin', 'set_lineout_volume.sh')

LINEIN_VOLUME_START = 150
PLAYLIST_VOLUME_START = 100

CONFIG_FILE_PATH = join(BASE_DIR, 'var', 'owltail.conf')
DEFAULT_SONGS_FOLDER = join(BASE_DIR, 'var', "songs")

SERIAL_NUMBER_READ_COMMAND = 'cat /proc/cpuinfo | grep microcode | head -n 1'


if os.environ.get('OWLTAIL_ENV') == 'production':
    CONFIG_FILE_PATH = '/var/lib/owltail/owltail.conf'
    DEFAULT_SONGS_FOLDER = "/var/lib/owltail/songs"

    PLAYER_LINEIN_TO_LINEOUT_CMD = '/usr/bin/linein_to_lineout.sh'
    PLAYER_PLAYBACK_TO_LINEOUT_CMD = '/usr/bin/playback_to_lineout.sh'
    PLAYER_NOTHING_TO_LINEOUT_CMD = '/usr/bin/nothing_to_lineout.sh'
    PLAYER_SET_VOLUME = '/usr/bin/set_lineout_volume.sh'
