def status(request): result = {"message": "failed"} try: vlc_config = get_vlc_config_from_redis() vlc = VLCController(vlc_config) result["status"] = vlc.get_common_info() result["message"] = "success" except Exception as e: print(e) result["error"] = str(e) return json_result(result)
def seek(request): result = {"message": "failed"} try: vlc_config = get_vlc_config_from_redis() vlc = VLCController(vlc_config) seconds = request.args.get("seconds") if seconds == False or seconds == None: seconds = 1 vlc.seek(seconds) result["status"] = vlc.get_common_info() result["message"] = "success" except Exception as e: print(e) result["error"] = str(e) return json_result(result)
def volume_down(request): result = {"message": "failed"} try: vlc_config = get_vlc_config_from_redis() vlc = VLCController(vlc_config) step = request.args.get("step") if step == False or step == None: step = 1 vlc.volume_down(step) result["status"] = vlc.get_common_info() result["message"] = "success" except Exception as e: print(e) result["error"] = str(e) return json_result(result)
def add(request): result = {"message": "failed"} try: vlc_config = get_vlc_config_from_redis() vlc = VLCController(vlc_config) file_path = request.args.get("file_path") vlc.add(file_path) time.sleep(1) vlc.fullscreen_on() result["status"] = vlc.get_common_info() result["message"] = "success" except Exception as e: print(e) result["error"] = str(e) return json_result(result)
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)
def play(request): result = {"message": "failed"} try: # 1.) Get State ensure_usb_drive_is_mounted() vlc_config = get_vlc_config_from_redis() vlc = VLCController(vlc_config) # 2.) Calculate Next Episode file_path = request.args.get("file_path") next_episode = get_next_episode(file_path) pprint(next_episode) # 3.) Play Episode vlc.add(next_episode["file_path"]) time.sleep(1) if int(next_episode["current_time"]) > 5: vlc.seek(int(next_episode["current_time"]) - 5) vlc.volume_set(100) time.sleep(3) vlc.fullscreen_on() # 4.) Get Status result["status"] = vlc.get_common_info() # 5.) Update Duration Meta Data 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)
def __init__(self): self.vlcController = VLCController() self.volumeController = VolumeController() self.mouseController = MouseController()
from vlc_controller import VLCController import time from pprint import pprint if __name__ == "__main__": vlc = VLCController() print(f"Connected = {vlc.connected}") vlc.add( "/media/187A29A07A297B9E/MEDIA_MANAGER/TVShows/TrailerParkBoys/12/Trailer.Park.Boys.S12E02.Godspeed.My.Muscular.Friend.1080p.NF.WEB-DL.DD5.1.H264-SiGMA.mkv" ) time.sleep(3) pprint(vlc.get_common_info())