Beispiel #1
0
def run_emergency_programs():
    global BLOCK_ICECAST_WATCHER

    path = "content/emergency_program"

    time.sleep(30)
    print(TAG, "EMERGENCY PROGRAM WATCHER")

    while (True):
        elements = os.listdir(path)

        for element in elements:
            if element.find(".mp3") >= 0:
                print(TAG, " --- emergency program --- ")

                instant_program = {
                    "title_show": element.replace(".mp3", ""),
                    "file": path + '/' + element
                }
                SongDownload.downloadOgg(instant_program)

                current_music_file = Helper.findLastPlayedFile()
                if (current_music_file.find("A") < 0):
                    copyfile(Constant.default_ogg_download_path,
                             Constant.currentA_path)
                else:
                    copyfile(Constant.default_ogg_download_path,
                             Constant.currentB_path)

                os.remove(path + '/' + element)

                skip_to_next_track()
            elif element.find(".ogg") >= 0:
                print(TAG, " --- emergency program --- ")

                instant_program = {
                    "title_show": element.replace(".ogg", ""),
                    "file": path + '/' + element
                }
                SongDownload.downloadOgg(instant_program)

                current_music_file = Helper.findLastPlayedFile()
                if (current_music_file.find("A") < 0):
                    copyfile(Constant.default_ogg_download_path,
                             Constant.currentA_path)
                else:
                    copyfile(Constant.default_ogg_download_path,
                             Constant.currentB_path)

                os.remove(path + '/' + element)

                skip_to_next_track()

        time.sleep(30)
Beispiel #2
0
def main():

    global next_music
    global prev_music
    global first_load

    current_title = getTitleFromIceCast()
    setTitleInFirebase(current_title)

    current_music_file = Helper.findLastPlayedFile()

    next_music = Scheduler.shuffle()

    if first_load == True:
        prev_music = next_music
        first_load = False

    else:
        while next_music["title_show"].find(prev_music["title_show"]) >= 0:
            next_music = Scheduler.shuffle()

    while SongDownload.downloadOgg(next_music) == False:
        next_music = Scheduler.shuffle()

    print(next_music)

    if (current_music_file.find("A") < 0):
        copyfile(Constant.default_ogg_download_path, Constant.currentA_path)
    else:
        copyfile(Constant.default_ogg_download_path, Constant.currentB_path)

    server_title = getTitleFromIceCast()
    while current_title.find(server_title) >= 0 and len(server_title) == len(
            current_title) and current_music_file.find(
                Helper.findLastPlayedFile()) == 0:
        time.sleep(5)
        server_title = getTitleFromIceCast()

    prev_music = next_music