def json_show_downloaded(request): file_path = request.GET["file_path"] file_name = os.path.basename(file_path) is_anime = request.GET["anime"] == "True" if not is_anime: showName = file_name.split(".")[0].replace("_", " ") epsNumber = file_name.split(".")[1] e = episode_data.objects.get(show=tv_shows.objects.get(name=showName), eps_number=epsNumber) e.downloaded = True e.uri = file_path e.save() ticker = "%s %s %s Downloaded|%s|%s" % (showName, epsNumber, e.eps_name, file_path, file_name) else: ticker = "%s Downloaded|%s|%s" % (file_name, file_path, file_name) # TODO: Here we need to only get remote devices in which show_view is checled for host in remote_devices.objects.all().filter(active=True): new_user = User.objects.get(id=host.user_id) cmd = command_queue( command="TMSG", command_text=ticker, source_hostname="FILE_SERVER", destination_hostname=host.devices_name, user=new_user, ) cmd.save() return JSONResponse(None, Extra={"success": True})
def json_delete_show(request): id = get_id(request) if id != None: cmd_string = "%s|%s|%s" % (request.GET["show_name"], request.GET["episode_name"], request.GET["episode_number"]) from_device = request.GET["device_name"] devices = remote_devices.objects.all().filter(active=True, user__id=id) new_user = User.objects.get(id=id) for device in devices: if from_device != device.devices_name: com_que = command_queue( command="DELS", command_text=cmd_string, source_hostname=from_device, destination_hostname=device.devices_name, user=new_user, ) com_que.save() return JSONResponse(None, Extra={"success": True}) else: return HttpResponseForbidden()
def json_send_command(request): id = get_id(request) if id is not None: response = {} command_in = request.GET["command"] command_text_in = request.GET["command_text"] source_hostname_in = request.GET["source_hostname"] destination_hostname_in = request.GET["destination_hostname"] if command_in != None: new_user = User.objects.get(id=id) com_que = command_queue( command=command_in, command_text=command_text_in, source_hostname=source_hostname_in, destination_hostname=destination_hostname_in, user=new_user, ) com_que.save() response["success"] = True else: response["success"] = False return JSONResponse(response, Extra={"success": True}) else: return HttpResponseForbidden()