Compare commits

..

No commits in common. "06869df15754962e36c18012358081c3dccf272e" and "266f56f8e6cad9039d67fab3ed08e0bcf78ee476" have entirely different histories.

6 changed files with 9 additions and 45 deletions

View File

@ -12,12 +12,6 @@ class Database():
def get_viewing_data(self, url:str ):
return (self.viewing_table.get(self.query.url == url))
def set_viewing_data(self, url:str, viewing_data: dict):
self.viewing_table.update(set(url, value), self.query.url == url)
def add_viewing_data(self, viewing_data):
self.viewing_table.insert(viewing_data)
def get_sites(self):
return (self.sites_table.all())

View File

@ -3,7 +3,7 @@ from scrapper import get_uri, get_files
from urllib.parse import quote, unquote
import player
from database import Database
import utils
from utils import get_url
import menu
def files_navigator(site: dict):
@ -14,7 +14,7 @@ def files_navigator(site: dict):
database.set_last_site(site.get("id"))
while True:
pos = database.get_last_cursor_pos()
path = get_uri(utils.get_base_url(site) + path)
path = get_uri(get_url(site) + path)
database.set_last_path(path)
file = menu.files(site, path, database, pos)
if (file == None):
@ -22,7 +22,7 @@ def files_navigator(site: dict):
elif (file == "../" and path == "/"):
return
if (not file.endswith("/")):
player.play(utils.get_base_url(site) + quote(path + file), database)
player.play(get_url(site) + quote(path + file), database)
else:
path = path + file

27
menu.py
View File

@ -1,10 +1,7 @@
from database import Database
from scrapper import get_files, get_uri, get_url
import utils
from utils import get
from scrapper import get_files, get_uri
from utils import get_url, get
import platform
import urllib
import colorama
from terminal_menu.Menu import Menu
@ -36,32 +33,14 @@ def files_preview(filename: str) -> str:
files = get_files(preview_site, uri + filename)
return ("\n".join(files))
def get_files_formated_by_viewing_data(database: Database, files: list, site: dict, path: str):
out = []
current_url = utils.get_base_url(site) + urllib.parse.quote(path);
for file in files:
if file == "..":
out.append(file);
continue
url = current_url + urllib.parse.quote(file)
print (url)
viewing_data = database.get_viewing_data(url);
if (viewing_data == None) or (viewing_data.get("finished") == False):
out.append(colorama.Style.BRIGHT + file + colorama.Style.RESET_ALL)
else:
out.append(colorama.Fore.LIGHTBLACK_EX + file + colorama.Style.RESET_ALL);
return (out);
def files(site:dict, path:str, database:Database, pos:int):
global uri
global preview_site
uri = path
preview_site = site
current_url = get_url(site, path);
files = get_files(site, path)
files_displayed = get_files_formated_by_viewing_data(database, files, site, path)
choose = get_user_choice_by_menu(files_displayed,
choose = get_user_choice_by_menu(files,
preview_command=files_preview,
preview_size=0.3,
show_search_hint=True,

View File

@ -1,6 +1,5 @@
from database import Database
import menu
import terminal_menu.Menu as terminal_menu
from time import sleep
import os, subprocess
@ -27,10 +26,6 @@ def _play(url: str, database: Database):
def play(url: str, database: Database):
viewing_data = database.get_viewing_data(url);
if (viewing_data == None):
viewing_data = {"url": url, "finished": True}
database.add_viewing_data(viewing_data);
with open(os.devnull, 'wb') as devnull:
subprocess.check_call(['vlc', url], stdout=devnull, stderr=subprocess.STDOUT)

View File

@ -1,14 +1,10 @@
from bs4 import BeautifulSoup
from urllib.parse import quote, unquote
import utils
from utils import get_url
import requests
def get_url(site: dict, path: str):
url = utils.get_base_url(site) + quote(path)
return (url)
def get_files(site:dict, path:str) -> []:
url = get_url(site, path)
url = get_url(site) + quote(path)
if (url in ["/../", "../"]):
return ([])
response = requests.get(url)

View File

@ -1,5 +1,5 @@
def get_base_url(site: dict):
def get_url(site: dict):
if (site.get("user") == "" and site.get("password") == ""):
return (f"http://{site.get('url')}")
else: