def next(request):
    result = {"message": "failed"}
    try:
        # 1.) Get State
        ensure_usb_drive_is_mounted()
        redis = redis_connect()
        config = redis.get("CONFIG.LOCAL_STORAGE_CONTROLLER_SERVER")
        config = json.loads(config)
        vlc_config = config["vlc"]

        # 2.) Advance to Next TV Show in Circular List
        next_tv_show_name_b64 = redis_circular_list.next(
            redis, "STATE.USB_STORAGE.LIBRARY.TV_SHOWS")
        next_tv_show_name = utils.base64_decode(next_tv_show_name_b64)

        # 3.) Advance to Next Episode in TV Show even though current one might be un-finished
        file_path_b64 = redis_circular_list.next(
            redis,
            f"STATE.USB_STORAGE.LIBRARY.TV_SHOWS.{next_tv_show_name_b64}")
        episode = get_current_episode(file_path_b64)

        # 4.) Start Episode
        vlc = VLCController(vlc_config)
        vlc.add(episode["file_path"])
        time.sleep(1)
        if int(episode["current_time"]) > 5:
            vlc.seek(int(episode["current_time"]) - 5)
        vlc.volume_set(100)
        time.sleep(3)
        vlc.fullscreen_on()

        # 5.) Get Status
        result["status"] = vlc.get_common_info()
        pprint(result["status"])

        # 6.) Update Duration
        update_duration_metadata(result["status"]["status"]["duration"],
                                 result["status"]["status"]["file_path"])

        result["message"] = "success"
    except Exception as e:
        print(e)
        result["error"] = str(e)
    return json_result(result)
Esempio n. 2
0
def playback_play():
    try:
        video = update_current_video_time_info()
        if video["over"] == True:
            redis = redis_connect()
            video = redis_circular_list.next(
                redis, "STATE.WEBSITES.DISNEY_PLUS.LIBRARY.VIDEOS")
            video = json.loads(video)
            video = update_current_video_time_info(video)
        #pprint( video )
        chrome = ChromeRDPWrapper()
        chrome.open_solo_url(f"https://www.disneyplus.com/video/{video['id']}")
        chrome.attach_xdo_tool("Disney+ | Video Player")
    except Exception as e:
        PrintException()
        return False
def get_next_episode(file_path=None):
    redis = redis_connect()
    if file_path is not None:
        file_path = utils.base64_encode(file_path)

    episode = get_current_episode(file_path)
    while is_episode_over(episode) == True:
        current_tv_show_name_b64 = redis_circular_list.current(
            redis, "STATE.USB_STORAGE.LIBRARY.TV_SHOWS")
        current_tv_show_name = utils.base64_decode(current_tv_show_name_b64)
        file_path_b64 = redis_circular_list.next(
            redis,
            f"STATE.USB_STORAGE.LIBRARY.TV_SHOWS.{current_tv_show_name_b64}")
        print(file_path_b64)
        episode = get_current_episode(file_path_b64)

    return episode
def play_uri(request):
    result = {"message": "failed", "status": None, "metadata": None}
    try:
        uri = request.args.get("uri")
        if uri == None:
            redis = redis_connect()
            uri = redis_circular_list.next(
                redis, "STATE.SPOTIFY.LIBRARY.PLAYLISTS.CURRATED")
        spotify_uri = decode_spotify_uri_string(uri)
        print(spotify_uri)
        spotify_dbus_controller = SpotifyDBusController()
        spotify_dbus_controller.open_uri(spotify_uri)
        time.sleep(.5)
        result["message"] = "success"
        result["status"] = spotify_dbus_controller.get_common_status()
    except Exception as e:
        print(e)
        result["error"] = str(e)
    return json(result)
Esempio n. 5
0
def playback_next():
    try:
        print("2.) playback_next()")

        print("\tReplay CNEE 'Checking Time'")
        cnee_check_time()

        redis = redis_connect()
        video = redis_circular_list.next(
            redis, "STATE.WEBSITES.DISNEY_PLUS.LIBRARY.VIDEOS")
        video = json.loads(video)
        video = update_current_video_time_info(video)

        # 2.) Exit Fullscreen and Manual Time Update
        print("\tReplay CNEE 'Prepare Next'")
        cnee_prepare_next()

        # 5.) Open Next Video
        print("\tOpen Next Video")
        time.sleep(3)
        chrome.open_solo_url(f"https://www.disneyplus.com/video/{video['id']}")
    except Exception as e:
        PrintException()
        return False