Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lekma committed Mar 18, 2021
1 parent 03024f4 commit f52e675
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 637 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.dlive"
name="DLive"
version="0.9.99"
version="1.0.0"
provider-name="lekma">

<requires>
Expand Down
6 changes: 2 additions & 4 deletions lib/dlive/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@


from iapc import Client

from tools import Logger, notify
from iapc.tools import Logger, notify

from .objects import Category, Categories, Streams, User, Users

Expand All @@ -28,7 +27,7 @@ class DLiveClient(object):
}

def __init__(self):
self.logger = Logger(component="client")
#self.logger = Logger(component="client")
self.__client__ = Client()

def __query__(self, query, list=False, **kwargs):
Expand Down Expand Up @@ -69,7 +68,6 @@ def categories(self, **kwargs):
return self.__query__("categories", list=True, **kwargs)

def search(self, **kwargs):
self.logger.info(f"search(kwargs={kwargs})")
return self.__query__(kwargs.pop("query"), list=True, **kwargs)


Expand Down
6 changes: 4 additions & 2 deletions lib/dlive/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

from datetime import datetime

from tools import localizedString, maybeLocalize, getAddonId, ListItem, buildUrl
from tools.objects import Type, Object, List
from iapc.tools import (
localizedString, maybeLocalize, getAddonId, ListItem, buildUrl
)
from iapc.tools.objects import Type, Object, List

from . import __schema__

Expand Down
5 changes: 3 additions & 2 deletions lib/dlive/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from collections import deque, OrderedDict

from tools import Persistent, save
from iapc.tools import Persistent, save, notify

from .objects import Queries
from .utils import searchDialog
Expand Down Expand Up @@ -55,7 +55,8 @@ def clear(self, **kwargs):
if (query := kwargs.get("query")):
self[query].clear()
else:
self.clear()
super().clear()
notify(30114, time=2000)

def history(self, category=None, **kwargs):
return Queries(
Expand Down
2 changes: 1 addition & 1 deletion lib/dlive/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-


from tools import (
from iapc.tools import (
localizedString, ListItem, buildUrl, getMedia, executeBuiltin, inputDialog
)

Expand Down
9 changes: 1 addition & 8 deletions lib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from sys import argv

from tools import Plugin, action, parseQuery, openSettings, getSetting
from iapc.tools import Plugin, action, parseQuery, openSettings, getSetting

from dlive import home, styles, search_queries
from dlive.client import client
Expand Down Expand Up @@ -72,7 +72,6 @@ def category(self, **kwargs):

@action()
def home(self, **kwargs):
self.logger.info(f"search_cache: {search_cache}")
if self.addDirectory(Folders(home)):
return self.addSettings()
return False
Expand Down Expand Up @@ -106,15 +105,13 @@ def categories(self, **kwargs):
# search -------------------------------------------------------------------

def __search__(self, **kwargs):
self.logger.info(f"__search__(kwargs={kwargs})")
search_cache.push(kwargs)
return self.addDirectory(
client.search(**kwargs),
search_queries[kwargs["query"]]["action"], **kwargs
)

def __new_search__(self, **kwargs):
self.logger.info(f"__new_search__(kwargs={kwargs})")
try:
kwargs = search_cache.pop()
except IndexError:
Expand All @@ -124,7 +121,6 @@ def __new_search__(self, **kwargs):
return False

def __history__(self, **kwargs):
self.logger.info(f"__history__(kwargs={kwargs})")
search_cache.clear()
if self.addNewSearch(**kwargs):
return self.addDirectory(
Expand All @@ -137,8 +133,6 @@ def __history__(self, **kwargs):

@action(category=30002)
def search(self, **kwargs):
self.logger.info(f"search(kwargs={kwargs})")
self.logger.info(f"search_cache: {search_cache}")
if "query" in kwargs:
new = kwargs.pop("new", False)
if "text" in kwargs:
Expand All @@ -147,7 +141,6 @@ def search(self, **kwargs):
return self.__new_search__(**kwargs)
return self.__history__(**kwargs)
search_cache.clear()
self.logger.info(f"search_cache: {search_cache}")
return self.addDirectory(self.getSubfolders("search"))

# settings -----------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from sys import argv

from tools import getAddonId, containerUpdate, containerRefresh
from iapc.tools import getAddonId, containerUpdate, containerRefresh

from dlive.persistence import search_history

Expand Down
17 changes: 8 additions & 9 deletions lib/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from requests import Session, Timeout

from iapc import Service, public

from tools import makeDataDir, getSetting, getLanguage, containerRefresh
from iapc.tools import makeProfile, getSetting, getLanguage, containerRefresh

from dlive.graphql import GraphQLError, queries
from dlive.utils import Cache
Expand Down Expand Up @@ -37,17 +36,18 @@ class DLiveSession(Session):

def __init__(self, logger, headers=None):
super().__init__()
self.logger = logger.getLogger("session")
self.logger = logger.getLogger("service.session")
if headers:
self.headers.update(headers)
self.__setup__()
self.__setup__(True)

def __setup__(self):
def __setup__(self, init=False):
if (timeout := getSetting("timeout", float)) <= 0.0:
self.timeout = None
else:
self.timeout = (((timeout - (timeout % 3)) + 0.05), timeout)
self.logger.info(f"timeout: {self.timeout}")
if not init:
self.logger.info(f"timeout: {self.timeout}")

def request(self, *args, **kwargs):
response = super().request(*args, timeout=self.timeout, **kwargs)
Expand All @@ -67,8 +67,8 @@ class DLiveService(Service):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__session__ = DLiveSession(self.logger, headers=self.__headers__)
self.__categories__ = Categories(self.query("categories", first=48))
makeDataDir()
self.__categories__ = Categories(self.query("categories", first=64))
makeProfile()

def start(self, **kwargs):
self.logger.info("starting...")
Expand Down Expand Up @@ -151,7 +151,6 @@ def categories(self, **kwargs):

@public
def search_users(self, **kwargs):
self.logger.info(f"search_users(kwargs={kwargs})")
result = self.query("search_users", first=self.__first__, **kwargs)
result["list"] = [item.get("creator", item) for item in result["list"]]
return result
Expand Down
12 changes: 0 additions & 12 deletions lib/tools/__init__.py

This file was deleted.

148 changes: 0 additions & 148 deletions lib/tools/addon.py

This file was deleted.

Loading

0 comments on commit f52e675

Please sign in to comment.