Fix take_screenshot for leeched files vframs deprecated

- Cleanup qbttorrent-selection web, preparing to add aria2c selection.

Signed-off-by: anasty17 <e.anastayyar@gmail.com>
This commit is contained in:
anasty17 2022-07-21 23:39:50 +03:00
parent 0cad914511
commit 37082a3d65
4 changed files with 20 additions and 29 deletions

View File

@ -106,7 +106,7 @@ def take_ss(video_file):
duration = duration // 2
status = srun(["new-api", "-hide_banner", "-loglevel", "error", "-ss", str(duration),
"-i", video_file, "-vframes", "1", des_dir])
"-i", video_file, "-frames:v", "1", des_dir])
if status.returncode != 0 or not ospath.lexists(des_dir):
return None

View File

@ -482,7 +482,7 @@ class GoogleDriveHelper:
str = str.replace(char, '\\' + char)
return str.strip()
def __get_recursive_list(self, file, rootid = "root"):
def __get_recursive_list(self, file, rootid):
rtnlist = []
if not rootid:
rootid = file.get('teamDriveId')

View File

@ -4,7 +4,7 @@
from anytree import NodeMixin
class TorNode(NodeMixin):
def __init__(self, name, is_folder=False, is_file=False, parent=None, progress=None, size=None, priority=None, file_id=None):
def __init__(self, name, is_folder=False, is_file=False, parent=None, size=None, priority=None, file_id=None):
super().__init__()
self.name = name
self.is_folder = is_folder
@ -12,8 +12,6 @@ class TorNode(NodeMixin):
if parent is not None:
self.parent = parent
if progress is not None:
self.progress = progress
if size is not None:
self.size = size
if priority is not None:
@ -38,7 +36,7 @@ def make_tree(res):
TorNode: Parent node of the tree constructed and can be used further.
"""
parent = TorNode("Torrent")
for l, i in enumerate(res):
for i in res:
# Get the hierarchy of the folders by splitting based on '/'
folders = get_folders(i.name)
# Check if the file is alone for if its in folder
@ -63,15 +61,15 @@ def make_tree(res):
# if the node is not found then create the folder node
# if the node is found then use it as base for the next
if current_node is None:
previous_node = TorNode(folders[j],parent=previous_node,is_folder=True)
previous_node = TorNode(folders[j], parent=previous_node, is_folder=True)
else:
previous_node = current_node
# at this point the previous_node will contain the deepest folder in it so add the file to it
TorNode(folders[-1],is_file=True,parent=previous_node,progress=i.progress,size=i.size,priority=i.priority,file_id=l)
TorNode(folders[-1], is_file=True, parent=previous_node, size=i.size, priority=i.priority, file_id=i.id)
else:
# at the file to the parent if no folders are there
TorNode(folders[-1],is_file=True,parent=parent,progress=i.progress,size=i.size,priority=i.priority,file_id=l)
return parent
TorNode(folders[-1], is_file=True, parent=parent, size=i.size, priority=i.priority, file_id=i.id)
return create_list(parent, ["", 0])
"""
def print_tree(parent):
@ -88,7 +86,7 @@ def create_list(par, msg):
msg[0] += "<li>"
if i.name != ".unwanted":
msg[0] += f'<input type="checkbox" name="foldernode_{msg[1]}"> <label for="{i.name}">{i.name}</label>'
create_list(i,msg)
create_list(i, msg)
msg[0] += "</li>"
msg[1] += 1
else:
@ -102,4 +100,5 @@ def create_list(par, msg):
msg[0] += "</li>"
if par.name != ".unwanted":
msg[0] += "</ul>"
msg[0] += "</ul>"
return msg

View File

@ -657,24 +657,21 @@ def re_verfiy(paused, resumed, client, hash_id):
paused = paused.split("|")
if resumed:
resumed = resumed.split("|")
k = 0
while True:
res = client.torrents_files(torrent_hash=hash_id)
verify = True
for i in res:
if str(i.id) in paused and i.priority != 0:
verify = False
break
if str(i.id) in resumed and i.priority == 0:
verify = False
break
if verify:
break
LOGGER.info("Reverification Failed: correcting stuff...")
LOGGER.info("Reverification Failed! Correcting stuff...")
client.auth_log_out()
sleep(1)
client = qbClient(host="localhost", port="8090")
@ -683,17 +680,17 @@ def re_verfiy(paused, resumed, client, hash_id):
except NotFound404Error:
raise NotFound404Error
except Exception as e:
LOGGER.error(f"{e} Errored in reverification paused")
LOGGER.error(f"{e} Errored in reverification paused!")
try:
client.torrents_file_priority(torrent_hash=hash_id, file_ids=resumed, priority=1)
except NotFound404Error:
raise NotFound404Error
except Exception as e:
LOGGER.error(f"{e} Errored in reverification resumed")
LOGGER.error(f"{e} Errored in reverification resumed!")
k += 1
if k > 5:
return False
LOGGER.info("Verified")
LOGGER.info(f"Verified! Hash: {hash_id}")
return True
@app.route('/app/files/<string:hash_id>', methods=['GET'])
@ -713,11 +710,7 @@ def list_torrent_contents(hash_id):
client = qbClient(host="localhost", port="8090")
res = client.torrents_files(torrent_hash=hash_id)
par = nodes.make_tree(res)
cont = ["", 0]
nodes.create_list(par, cont)
cont = nodes.make_tree(res)
client.auth_log_out()
return page.replace("{My_content}", cont[0]).replace("{form_url}", f"/app/files/{hash_id}?pin_code={pincode}")
@ -730,7 +723,7 @@ def set_priority(hash_id):
data = dict(request.form)
for i, value in data.items():
if i.find("filenode") != -1:
if "filenode" in i:
node_no = i.split("_")[-1]
if value == "on":
@ -740,7 +733,6 @@ def set_priority(hash_id):
pause = pause.strip("|")
resume = resume.strip("|")
try:
client.torrents_file_priority(torrent_hash=hash_id, file_ids=pause, priority=0)
except NotFound404Error:
@ -753,9 +745,9 @@ def set_priority(hash_id):
raise NotFound404Error
except Exception as e:
LOGGER.error(f"{e} Errored in resumed")
sleep(2)
sleep(1)
if not re_verfiy(pause, resume, client, hash_id):
LOGGER.error("Verification Failed")
LOGGER.error(f"Verification Failed! Hash: {hash_id}")
client.auth_log_out()
return list_torrent_contents(hash_id)