Skip to content

Commit

Permalink
mega-ls on startup to invoke mega-cmd-server if not already invoked
Browse files Browse the repository at this point in the history
  • Loading branch information
ritiek committed Dec 28, 2018
1 parent a346842 commit 00d5ff5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<addon id="plugin.video.megacmd" name="MegaCMD" provider-name="Ritiek Malhotra (@ritiek)" version="0.1.2">
<addon id="plugin.video.megacmd" name="MegaCMD" provider-name="Ritiek Malhotra (@ritiek)" version="0.1.3">
<requires>
<import addon="xbmc.python" version="2.1.0" />
<import addon="script.module.xbmcswift2" version="1.1.1" />
Expand Down
13 changes: 9 additions & 4 deletions resources/megacmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
import urllib


MEGA_CMD_PATH = "mega"

# A simple command to invoke mega-cmd-server if not already invoked
subprocess.call(MEGA_CMD_PATH + "-" + "ls")


def get_output(cmd):
cmd = ["mega-" + cmd[0]] + cmd[1:]
cmd = [MEGA_CMD_PATH + "-" + cmd[0]] + cmd[1:]
output = subprocess.check_output(cmd)
output_splits = output.decode("utf-8").split("\n")
output_splits.remove("")
Expand All @@ -12,13 +18,13 @@ def get_output(cmd):

def list_files(megapath="."):
files_list = get_output(["ls", megapath])
attrs_list = get_output(["ls", "-l", megapath])#[1:]
attrs_list = get_output(["ls", "-l", megapath])

if files_list[0] == attrs_list[0]:
files_list.pop(0)
attrs_list.pop(0)

attrs_list = attrs_list[1:]
attrs_list.pop(0)
files_info = []

for filename, attrs in zip(files_list, attrs_list):
Expand All @@ -27,7 +33,6 @@ def list_files(megapath="."):
file_info = {"name": filename,
"is_dir": is_dir,
"path": path,
#"url": webdav + urllib.quote(path)}
"url": webdav_url(path)}

# if is_dir:
Expand Down

0 comments on commit 00d5ff5

Please sign in to comment.