Skip to content

Commit

Permalink
release: v1.33.0
Browse files Browse the repository at this point in the history
  • Loading branch information
newt-sc committed Nov 28, 2021
1 parent 993af83 commit b1637df
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 42 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* [v1.33.0](https://github.com/newt-sc/a4kStreaming/releases/tag/plugin.video.a4kstreaming%2Fplugin.video.a4kstreaming-1.33.0):
* Add recommended providers usage for general speedup

* [v1.32.0](https://github.com/newt-sc/a4kStreaming/releases/tag/plugin.video.a4kstreaming%2Fplugin.video.a4kstreaming-1.32.0):
* Back navigation from source files browsing

Expand Down
10 changes: 8 additions & 2 deletions a4kStreaming/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2271,7 +2271,7 @@ def play(core, params):
season_results = None
pack_results = None

if len(last_results) > 50:
while len(last_results) > 10:
oldest_key = list(last_results.keys())[0]
for key in last_results:
if last_results[key]['time'] < last_results[oldest_key]['time']:
Expand Down Expand Up @@ -2500,7 +2500,10 @@ def delete_magnet():
core.threading.Thread(target=delete_magnet).start()
return files

link = None
link = result.get('url', None)
if link:
goto .play # type: ignore # noqa: F821

files = []
if result.get('debrid', 'PM') == 'PM':
try: files = resolve_pm()
Expand Down Expand Up @@ -2594,7 +2597,10 @@ def delete_magnet():
except:
core.logger.notice(core.traceback.format_exc())

label .play # type: ignore # noqa: F821
item = core.kodi.xbmcgui.ListItem(path=link, offscreen=True)
item.setProperty('IsPlayable', 'true')
item.setContentLookup(False)

video_meta = provider_params.title.copy()
video_meta.pop('tvshowseasonid', None)
Expand Down
5 changes: 4 additions & 1 deletion a4kStreaming/lib/debrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ def premiumize_transfers(apikey):
}

def premiumize_files(apikey, id):
if id != '':
id = 'id=%s&' % id

return {
'method': 'GET',
'url': 'https://www.premiumize.me/api/folder/list?id=%s&includebreadcrumbs=false&apikey=%s' % (id, apikey),
'url': 'https://www.premiumize.me/api/folder/list?%sincludebreadcrumbs=false&apikey=%s' % (id, apikey),
'headers': {
'content-type': 'application/json',
},
Expand Down
2 changes: 2 additions & 0 deletions a4kStreaming/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import zipfile
import shutil
import time
import base64
from datetime import datetime
from io import BytesIO
from itertools import islice
Expand All @@ -34,6 +35,7 @@
default_encoding = 'utf-8'
zip_utf8_flag = 0x800
py3_zip_missing_utf8_flag_fallback_encoding = 'cp437'
recommended = base64.b64decode('VE9SUkVOVElP')

temp_dir = os.path.join(kodi.addon_profile, 'temp')
provider_temp_dir = os.path.join(kodi.addon_profile, 'provider-temp')
Expand Down
91 changes: 62 additions & 29 deletions a4kStreaming/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,54 @@ def __search(core, params):
return {}

sources = {}
for key in provider:
if not provider[key]:
continue

try:
source = core.importlib.import_module(__sources_module_name(core) + ('.%s' % key.lower()))
sources[key] = source.sources()
except: pass
use_recommended = core.kodi.get_bool_setting('provider.use_recommended')
recommended = core.utils.recommended
try:
source = core.importlib.import_module(__sources_module_name(core) + ('.%s' % recommended.lower()))
sources[recommended] = source.sources()
except: pass

if len(sources) == 0 or not use_recommended:
use_recommended = False
for key in provider:
if not provider[key] or key == recommended:
continue

try:
source = core.importlib.import_module(__sources_module_name(core) + ('.%s' % key.lower()))
sources[key] = source.sources()
except: pass

threads = []
search = lambda: None
search.results = {}
search.cached = {}

premiumize_apikey = core.utils.get_premiumize_apikey(core)
realdebrid_apikey = core.utils.get_realdebrid_apikey(core)
alldebrid_apikey = core.utils.get_alldebrid_apikey(core)
use_direct_urls = False

for key in sources.keys():
def get_sources(key):
source = sources[key]
results = []
try:
apikeys = {}
if use_direct_urls:
apikeys = {
'pm': premiumize_apikey,
'rd': realdebrid_apikey,
'ad': alldebrid_apikey
}

if params.title.mediatype == 'movie':
try:
results += source.movie(params.title.title, params.title.year, params.title.imdbnumber)
results += source.movie(params.title.title, params.title.year, params.title.imdbnumber, apikeys=apikeys)
except Exception as e:
if 'movie() takes' in str(e):
results += source.movie(params.title.title, params.title.year)
results += source.movie(params.title.title, params.title.year, apikeys=apikeys)
else:
core.logger.notice(core.traceback.format_exc())
else:
Expand All @@ -202,7 +225,7 @@ def get_sources(key):
'is_airing': params.title.is_airing
}
all_info = { 'info': { 'tvshow.imdb_id': params.title.tvshowid } }
results += source.episode(simple_info, all_info)
results += source.episode(simple_info, all_info, apikeys=apikeys)

if len(results) <= 0:
return
Expand Down Expand Up @@ -302,24 +325,33 @@ def rd(apikey):
def ad(apikey):
sanitize_results(check_ad(apikey), 'AD')

threads = []

premiumize_apikey = core.utils.get_premiumize_apikey(core)
if premiumize_apikey:
threads.append(core.threading.Thread(target=pm, args=(premiumize_apikey,)))

realdebrid_apikey = core.utils.get_realdebrid_apikey(core)
if realdebrid_apikey:
threads.append(core.threading.Thread(target=rd, args=(realdebrid_apikey,)))

alldebrid_apikey = core.utils.get_alldebrid_apikey(core)
if alldebrid_apikey:
threads.append(core.threading.Thread(target=ad, args=(alldebrid_apikey,)))
def sanitize_direct_url_results():
for result in results:
result = result.copy()
result['ref'] = params.title
size = float(result['size']) / 1024
result['size'] = round(size, 1)
core.utils.cleanup_result(result)
if search.results.get(result['url'], None) is None:
search.results[result['url']] = result
result['title_with_debrid'] = '%s | %s' % (result['debrid'], result['title'])
search.cached['%s%s' % (result['debrid'], result['url'])] = result

for thread in threads:
thread.start()
for thread in threads:
thread.join()
if use_direct_urls:
sanitize_direct_url_results()
else:
threads = []
if premiumize_apikey:
threads.append(core.threading.Thread(target=pm, args=(premiumize_apikey,)))
if realdebrid_apikey:
threads.append(core.threading.Thread(target=rd, args=(realdebrid_apikey,)))
if alldebrid_apikey:
threads.append(core.threading.Thread(target=ad, args=(alldebrid_apikey,)))

for thread in threads:
thread.start()
for thread in threads:
thread.join()

except Exception as e:
core.logger.notice(e)
Expand Down Expand Up @@ -373,8 +405,9 @@ def execute():
time_after_start = core.utils.time_ms() - params.start_time
if time_after_start < 1000:
core.kodi.xbmc.sleep(int(round(1000 - time_after_start)))
progress.create(core.kodi.addon_name, *progress_msg())
search.dialog = True
if not use_recommended:
progress.create(core.kodi.addon_name, *progress_msg())
search.dialog = True

chunk_size = len(sources)
for chunk in core.utils.chunk(threads, chunk_size):
Expand Down
5 changes: 4 additions & 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.a4kstreaming"
name="a4kStreaming"
version="1.32.0"
version="1.33.0"
provider-name="Unknown">
<requires>
<import addon="script.module.requests"/>
Expand Down Expand Up @@ -32,6 +32,9 @@ Designed for low-end devices and Estuary skin.
<screenshot>screenshot-06.jpg</screenshot>
</assets>
<news>
[v1.33.0]:
* Add recommended providers usage for general speedup

[v1.32.0]:
* Back navigation from source files browsing

Expand Down
5 changes: 4 additions & 1 deletion packages/addons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<addons>
<addon id="plugin.video.a4kstreaming"
name="a4kStreaming"
version="1.32.0"
version="1.33.0"
provider-name="Unknown">
<requires>
<import addon="script.module.requests"/>
Expand Down Expand Up @@ -35,6 +35,9 @@ Designed for low-end devices and Estuary skin.
<screenshot>screenshot-06.jpg</screenshot>
</assets>
<news>
[v1.33.0]:
* Add recommended providers usage for general speedup

[v1.32.0]:
* Back navigation from source files browsing

Expand Down
2 changes: 1 addition & 1 deletion packages/addons.xml.crc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3551276326d6a3558e0748757b1a431d81bd9268
37360db3c14234cbc4d347aa5b2f24a06582bb7b
10 changes: 7 additions & 3 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,14 @@ msgid "Install"
msgstr ""

msgctxt "#33302"
msgid "Manage"
msgid "Use recommended"
msgstr ""

msgctxt "#33303"
msgid "Manage"
msgstr ""

msgctxt "#33304"
msgid "Check for an update"
msgstr ""

Expand Down Expand Up @@ -218,11 +222,11 @@ msgid "Migrate Trakt.tv's watched status to IMDb (via rating)"
msgstr ""

msgctxt "#33602"
msgid "Trakt API key (Client ID): "
msgid "Trakt API key/Client ID (!used only for migration!): "
msgstr ""

msgctxt "#33603"
msgid "Trakt username (User slug): "
msgid "Trakt username/slug (!used only for migration!): "
msgstr ""

msgctxt "#33604"
Expand Down
7 changes: 4 additions & 3 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
</category>
<!-- Provider -->
<category label="33003">
<setting id="provider.install" type="action" label="33301" action="RunPlugin(plugin://plugin.video.a4kstreaming/?action=provider&type=install)"/>
<setting id="provider.manage" type="action" label="33302" action="RunPlugin(plugin://plugin.video.a4kstreaming/?action=provider&type=manage)"/>
<setting id="provider.check" type="action" label="33303" action="RunPlugin(plugin://plugin.video.a4kstreaming/?action=provider&type=new_version_check)"/>
<setting id="provider.install" type="action" label="33301" action="RunPlugin(plugin://plugin.video.a4kstreaming/?action=provider&type=install)"/>
<setting id="provider.use_recommended" type="bool" label="33302" default="true"/>
<setting id="provider.manage" type="action" label="33303" action="RunPlugin(plugin://plugin.video.a4kstreaming/?action=provider&type=manage)" enable="eq(-1,false)"/>
<setting id="provider.check" type="action" label="33304" action="RunPlugin(plugin://plugin.video.a4kstreaming/?action=provider&type=new_version_check)"/>
</category>
<!-- Debrid -->
<category label="33004">
Expand Down
15 changes: 14 additions & 1 deletion tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def select(*args, **kwargs): return 1
provider = a4kstreaming_api.core.cache.get_provider()
selected = {}
for key in provider.keys():
if len(key) == 8:
if len(key) == 8 or settings.get('provider.use_recommended', 'false') == 'true':
selected[key] = True
a4kstreaming_api.core.cache.save_provider(selected)

Expand All @@ -68,6 +68,7 @@ def __invoke(a4kstreaming_api, action, params={}, settings={}, prerun=None, remo
'views.episodes': '0',
'views.season': '0',
'views.episode': '0',
'provider.use_recommended': 'false',
'premiumize.apikey': premiumize_apikey,
'realdebrid.apikey': realdebrid_apikey,
'alldebrid.apikey': alldebrid_apikey,
Expand Down Expand Up @@ -139,6 +140,18 @@ def prerun():

assert play.results is not None

def test_play_movie_pm_using_recommended():
a4kstreaming_api = api.A4kStreamingApi({'kodi': True})

settings = { 'realdebrid.apikey': '', 'alldebrid.apikey': '', 'provider.use_recommended': 'true' }
def prerun():
__setup_provider(a4kstreaming_api, settings)

title = b'eyJtZWRpYXR5cGUiOiAibW92aWUiLCAiaW1kYm51bWJlciI6ICJ0dDAxMDgxNjAiLCAidGl0bGUiOiAiU2xlZXBsZXNzIGluIFNlYXR0bGUiLCAib3JpZ2luYWx0aXRsZSI6ICJTbGVlcGxlc3MgaW4gU2VhdHRsZSIsICJ0dnNob3dpZCI6IG51bGwsICJzZWFzb25zIjogbnVsbCwgInR2c2hvd3RpdGxlIjogIiIsICJ5ZWFyIjogMTk5MywgInByZW1pZXJlZCI6ICIxOTkzLTYtMjUiLCAiZHVyYXRpb24iOiA2MzAwLCAibXBhYSI6ICJQRyIsICJnZW5yZSI6IFsiQ29tZWR5IiwgIkRyYW1hIiwgIlJvbWFuY2UiXSwgImNvdW50cnkiOiBbIlVuaXRlZCBTdGF0ZXMiXSwgInRyYWlsZXIiOiAiP2FjdGlvbj10cmFpbGVyJmlkPXZpNzI3MzY3NDQ5IiwgInBsb3QiOiAiQSByZWNlbnRseSB3aWRvd2VkIG1hbidzIHNvbiBjYWxscyBhIHJhZGlvIHRhbGstc2hvdyBpbiBhbiBhdHRlbXB0IHRvIGZpbmQgaGlzIGZhdGhlciBhIHBhcnRuZXIuIiwgInRhZ2xpbmUiOiAiV2hhdCBpZiBzb21lb25lIHlvdSBuZXZlciBtZXQsIHNvbWVvbmUgeW91IG5ldmVyIHNhdywgc29tZW9uZSB5b3UgbmV2ZXIga25ldyB3YXMgdGhlIG9ubHkgc29tZW9uZSBmb3IgeW91PyIsICJvdmVybGF5IjogMCwgInN0dWRpbyI6IFsiVHJpU3RhciBQaWN0dXJlcyIsICJUcmlTdGFyIFBpY3R1cmVzIiwgIkNvbHVtYmlhIFRyaVN0YXIgRmlsbSJdLCAiZGlyZWN0b3IiOiBbIk5vcmEgRXBocm9uIl0sICJ3cml0ZXIiOiBbIkplZmYgQXJjaCIsICJOb3JhIEVwaHJvbiIsICJEYXZpZCBTLiBXYXJkIl19'
play = __invoke(a4kstreaming_api, 'play', { 'type': title }, settings=settings, prerun=prerun)

assert play.results is not None

def test_trailer():
a4kstreaming_api = api.A4kStreamingApi({'kodi': True})

Expand Down

0 comments on commit b1637df

Please sign in to comment.