Skip to content

Commit

Permalink
Merge pull request #24 from anxdpanic/dev
Browse files Browse the repository at this point in the history
5.0.0
  • Loading branch information
anxdpanic authored Oct 7, 2019
2 parents 0e7fd60 + 0e1e303 commit 908d7c6
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 206 deletions.
8 changes: 3 additions & 5 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.playthis" name="PlayThis" version="4.0.1" provider-name="anxdpanic">
<addon id="plugin.video.playthis" name="PlayThis" version="5.0.0" provider-name="anxdpanic">
<requires>
<import addon="xbmc.python" version="2.24.0"/>
<import addon="script.module.six" version="1.11.0"/>
<import addon="script.module.youtube.dl" version="18.619.0"/>
<import addon="plugin.video.youtube" version="6.2.0" optional="true"/>
<import addon="script.module.resolveurl" version="5.0.0" optional="true"/>
<import addon="script.module.resolveurl.xxx" version="2.0.0" optional="true"/>
</requires>
<extension point="xbmc.python.pluginsource" library="resources/lib/__run__.py">
<provides>executable video audio image</provides>
</extension>
<extension point="xbmc.addon.metadata">
<news>
[rem] URLResolver as optional dependency
[chg] only use youtube-dl to resolve content
</news>
<assets>
<icon>icon.png</icon>
Expand All @@ -27,7 +25,7 @@
<summary lang="en_GB">Find and resolve media from a url to play or open.</summary>
<description lang="en_GB">
PlayThis will attempt to find and resolve* media from a url to play or open. A history list is available for future use, exporting to .m3u/.strm** and sending to a remote PlayThis add-on. Supports video, audio, images and executable***.
* resolves using youtube-dl and ResolveURL(optional)
* resolves using youtube-dl
** exported .m3u/.strm is only usable in Kodi w/ PlayThis installed
*** 'executable' items are urls with potential results available through scraping

Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
5.0.0
[chg] only use youtube-dl to resolve content

4.0.1
[rem] URLResolver as optional dependency

Expand Down
3 changes: 0 additions & 3 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,3 @@ msgctxt "#30724"
msgid "No Video Link Found"
msgstr ""

msgctxt "#30725"
msgid "ResolveURL settings"
msgstr ""
4 changes: 0 additions & 4 deletions resources/language/resource.language.he_il/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,3 @@ msgstr "פתור/בצע סקרייפ מקומי"
msgctxt "#30724"
msgid "No Video Link Found"
msgstr ""

msgctxt "#30725"
msgid "ResolveURL settings"
msgstr ""
7 changes: 1 addition & 6 deletions resources/lib/addon_lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ def __enum(**enums):
ADDON_DATA_DIR = kodi.translate_path('special://profile/addon_data/%s/' % kodi.get_id())
THUMBNAILS_DIR = kodi.translate_path('special://thumbnails/')

RESOLVEURL_DIRS = [kodi.translate_path('special://home/addons/{0!s}/resources/lib/addon_lib/resolvers/resolveurl/'.format(kodi.get_id())),
kodi.translate_path('special://home/addons/script.module.resolveurl.xxx/resources/plugins/')]

COOKIE_FILE = kodi.translate_path('special://temp/%s/cookies.lwp' % kodi.get_id())

MODES = __enum(
Expand All @@ -48,13 +45,11 @@ def __enum(**enums):
CLEARCOOKIES='clearcookies',
YOUTUBEDL='ytdl',
EXPORT_MENU='export_menu',
MANAGE_MENU='manage_menu',
RESOLVEURL='resolveurl')
MANAGE_MENU='manage_menu')

ICONS = __enum(
ADDON=kodi.translate_path('special://home/addons/{0!s}/icon.png'.format(kodi.get_id())),
KODI=kodi.translate_path('special://xbmc/media/icon256x256.png'),
RESOLVEURL=kodi.translate_path('special://home/addons/script.module.resolveurl/icon.png'),
YOUTUBEDL=kodi.translate_path('special://home/addons/script.module.youtube.dl/icon.png'),
YOUTUBE=kodi.translate_path('special://home/addons/plugin.video.youtube/icon.png'))

Expand Down
101 changes: 15 additions & 86 deletions resources/lib/addon_lib/playback.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,14 @@
from .urlresolver_helpers import get_hidden
from .urlresolver_helpers import append_headers
from .urlresolver_helpers import get_packed_data
from .constants import RESOLVEURL_DIRS
from .constants import COOKIE_FILE
from .constants import ICONS
from .constants import MODES
from .constants import RAND_UA
from .constants import FF_USER_AGENT


has_resolveurl = None
has_youtube = None

try:
from resolveurl import add_plugin_dirs, HostedMediaFile

has_resolveurl = 'ResolveURL'
except ImportError:
pass

try:
import youtube_resolver

Expand Down Expand Up @@ -297,7 +287,7 @@ def __check_for_new_url(url):
if 'youtu.be' in url:
result = re.search(r'http[s]*://youtu\.be/(?P<video_id>[a-zA-Z0-9_\-]{11})', url)
if result:
return 'https://www.youtube.com/watch?v=%s' % result.group('video_id')
return 'https://www.youtube.com/watch?v=%s' % result.group('video_id')

return url

Expand Down Expand Up @@ -371,39 +361,25 @@ def scrape_supported(url, html, regex):
links.append({'label': label, 'url': stream_url, 'resolver': resolver_name, 'content_type': 'video'})
continue

if has_resolveurl:
hmf = HostedMediaFile(url=stream_url, include_disabled=False)
is_valid = hmf.valid_url()
else:
is_valid = False

potential_type = __get_potential_type(stream_url)
is_valid_type = (potential_type != 'audio') and (potential_type != 'image')

if is_valid and is_valid_type:
resolver_name = has_resolveurl
if potential_type == 'text':
if ytdl_supported(stream_url):
progress_dialog.update(percent, kodi.i18n('check_for_support'),
'%s [%s]: %s' % (kodi.i18n('support_potential'), 'video', 'youtube-dl'),
'[%s]: %s' % (label, stream_url))
links.append({'label': label, 'url': stream_url, 'resolver': 'youtube-dl', 'content_type': 'video'})
continue
progress_dialog.update(percent, kodi.i18n('check_for_support'),
'%s [%s]: %s' % (kodi.i18n('support_potential'), 'video', resolver_name),
'%s [%s]: %s' % (kodi.i18n('support_potential'), potential_type, 'None'),
'[%s]: %s' % (label, stream_url))
links.append({'label': label, 'url': stream_url, 'resolver': resolver_name, 'content_type': 'video'})
continue
else:
if potential_type == 'text':
if ytdl_supported(stream_url):
progress_dialog.update(percent, kodi.i18n('check_for_support'),
'%s [%s]: %s' % (kodi.i18n('support_potential'), 'video', 'youtube-dl'),
'[%s]: %s' % (label, stream_url))
links.append({'label': label, 'url': stream_url, 'resolver': 'youtube-dl', 'content_type': 'video'})
continue
progress_dialog.update(percent, kodi.i18n('check_for_support'),
'%s [%s]: %s' % (kodi.i18n('support_potential'), potential_type, 'None'),
'[%s]: %s' % (label, stream_url))
else:
progress_dialog.update(percent, kodi.i18n('check_for_support'),
'%s [%s]: %s' % (kodi.i18n('support_potential'), potential_type, 'Kodi'),
'[%s]: %s' % (label, stream_url))
links.append({'label': label, 'url': stream_url, 'resolver': None, 'content_type': potential_type})
continue
progress_dialog.update(percent, kodi.i18n('check_for_support'),
'%s [%s]: %s' % (kodi.i18n('support_potential'), potential_type, 'Kodi'),
'[%s]: %s' % (label, stream_url))
links.append({'label': label, 'url': stream_url, 'resolver': None, 'content_type': potential_type})
continue

if progress_dialog.is_canceled():
sys.exit(0)
break
Expand Down Expand Up @@ -443,33 +419,6 @@ def resolve_yt_addon(url):
return {'label': label, 'resolved_url': stream_url, 'content_type': content_type, 'thumbnail': thumbnail, 'headers': headers}


@cache.cache_function(cache_limit=resolver_cache_limit)
def resolve(url, title=''):
resolver_dirs = []
resolver_name = has_resolveurl
_resolver_dirs = RESOLVEURL_DIRS
for plugin_path in _resolver_dirs:
if kodi.vfs.exists(plugin_path):
resolver_dirs.append(plugin_path)
if resolver_dirs:
add_plugin_dirs(resolver_dirs)

log_utils.log('Attempting to resolve: |{0!s}|'.format(url), log_utils.LOGDEBUG)
source = HostedMediaFile(url=url, title=title, include_disabled=False)
if not source:
log_utils.log('Not supported by {1!s}: |{0!s}|'.format(url, resolver_name), log_utils.LOGDEBUG)
return None
try:
resolved = source.resolve()
except:
resolved = None
if not resolved or not isinstance(resolved, string_types):
log_utils.log('Unable to resolve: |{0!s}|'.format(url), log_utils.LOGDEBUG)
return None
else:
return resolved


@cache.cache_function(cache_limit=resolver_cache_limit)
def resolve_youtube_dl(url):
label = None
Expand Down Expand Up @@ -536,8 +485,6 @@ def __pick_source(sources):
elif source['resolver'] == 'youtube-dl':
icon = ICONS.YOUTUBEDL

elif source['resolver'] == 'ResolveURL':
icon = ICONS.RESOLVEURL
l_item = kodi.ListItem(label=title, label2=label2)
l_item.setArt({'icon': icon, 'thumb': icon})
listitem_sources.append(l_item)
Expand Down Expand Up @@ -618,8 +565,6 @@ def scrape(url):
content_type = yt_result['content_type']
headers = yt_result['headers']
thumbnail = yt_result['thumbnail']
elif chosen['resolver'] == 'ResolveURL':
resolved = resolve(chosen['url'], title=chosen['label'])
if chosen['resolver'] == 'youtube-dl' or not resolved:
ytdl_result = resolve_youtube_dl(chosen['url'])
label = ytdl_result['label']
Expand Down Expand Up @@ -807,22 +752,6 @@ def play_this(item, title='', thumbnail='', player=True, history=None):
'%s: %s' % (kodi.i18n('resolution_successful'), source))
stream_url = source

if not stream_url:
resolver_name = has_resolveurl
progress_dialog.update(60, '%s: %s' % (kodi.i18n('source'), item), '%s: %s' % (kodi.i18n('attempt_resolve_with'), resolver_name), ' ')
if has_resolveurl:
source = resolve(item, title=title)
if source:
log_utils.log('Source |{0}| was |{1} supported|'.format(source, resolver_name), log_utils.LOGDEBUG)
sd_result = __check_smil_dash(source, headers)
source = sd_result['url']
is_dash = sd_result['is_dash']
if source:
progress_dialog.update(98, '%s: %s' % (kodi.i18n('source'), item),
'%s: %s' % (kodi.i18n('attempt_resolve_with'), resolver_name),
'%s: %s' % (kodi.i18n('resolution_successful'), source))
stream_url = source

if not stream_url:
if progress_dialog.is_canceled():
sys.exit(0)
Expand Down
12 changes: 0 additions & 12 deletions resources/lib/addon_lib/resolvers/__init__.py

This file was deleted.

10 changes: 0 additions & 10 deletions resources/lib/addon_lib/resolvers/resolveurl/__init__.py

This file was deleted.

70 changes: 0 additions & 70 deletions resources/lib/addon_lib/resolvers/resolveurl/reddit.py

This file was deleted.

9 changes: 0 additions & 9 deletions resources/lib/addon_lib/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from .remote import HttpJSONRPC
from .url_dispatcher import URL_Dispatcher


DISPATCHER = URL_Dispatcher()


Expand Down Expand Up @@ -238,14 +237,6 @@ def clear_cookies():
kodi.notify(msg=kodi.i18n('cookies_failed'), sound=False)


@DISPATCHER.register(MODES.RESOLVEURL)
def resolveurl_settings():
try:
kodi.Addon(id='script.module.resolveurl').openSettings()
except RuntimeError:
pass


@DISPATCHER.register(MODES.YOUTUBEDL)
def youtubedl_settings():
kodi.Addon(id='script.module.youtube.dl').openSettings()
Expand Down
1 change: 0 additions & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
</category>
<!-- Resolvers -->
<category label="30709">
<setting label="30725" id="resolveurl-settings" type="action" option="close" action="RunPlugin(plugin://$ID/?mode=resolveurl)" visible="System.HasAddon(script.module.resolveurl)"/>
<setting label="30712" id="youtube-dl-settings" type="action" option="close" action="RunPlugin(plugin://$ID/?mode=ytdl)"/>
<setting id="current_ua" type="text" default="" visible="false" enable="true"/>
<setting id="last_ua_create" type="text" default="" visible="false" enable="true"/>
Expand Down

0 comments on commit 908d7c6

Please sign in to comment.