Created
February 18, 2020 17:52
-
-
Save henryjfry/ea87043d55e0d9071327c77c618becfa to your computer and use it in GitHub Desktop.
OPENMETA - play_stream route ==> /home/osmc/.kodi/addons/plugin.video.openmeta/resources/lib/play_base.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
@plugin.route('/play_stream/<label>') | |
def play_stream(label): | |
import sys | |
import xbmcplugin | |
import xbmcgui | |
import os | |
addon_handle = int(sys.argv[1]) | |
xbmc.log(str(xbmcgui.getCurrentWindowDialogId())+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
# import xbmcaddon | |
# AddonName = xbmc.getInfoLabel('Container.PluginName') | |
# AddonName = xbmcaddon.Addon(AddonName).getAddonInfo('name') | |
# xbmc.log(str(AddonName) + '===AddonName===>play3', level=xbmc.LOGNOTICE) | |
if xbmcgui.getCurrentWindowDialogId() <> 10138 or 'Play with ' in xbmc.getInfoLabel('System.CurrentControl') or 'Search ' in xbmc.getInfoLabel('System.CurrentControl'): | |
# xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path='')) | |
xbmcplugin.endOfDirectory(addon_handle) | |
exit() | |
# if xbmcgui.getCurrentWindowDialogId() <> 10138: | |
# xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path='')) | |
# xbmcplugin.endOfDirectory(addon_handle) | |
# exit() | |
# else: | |
# xbmcplugin.endOfDirectory(addon_handle) | |
# | |
# import fcntl | |
# x = open('/home/osmc/.kodi/addons/plugin.video.themoviedb.helper/resources/lib/__init__.py', 'r+') | |
# | |
# if 'Play with ' in xbmc.getInfoLabel('System.CurrentControl') or 'Search ' in xbmc.getInfoLabel('System.CurrentControl'): | |
# | |
# try: | |
# f= open('/home/osmc/' + sys.argv[2],"w+") | |
# f.close | |
# except: | |
# pass | |
# os.remove('/home/osmc/' + sys.argv[2]) | |
# | |
# fcntl.flock(x, fcntl.LOCK_UN) | |
# xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path='')) | |
# xbmcplugin.endOfDirectory(addon_handle) | |
# exit() | |
# else: | |
# | |
# try: | |
# fcntl.flock(x, fcntl.LOCK_EX| fcntl.LOCK_NB) | |
# except: | |
# xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path='')) | |
# xbmcplugin.endOfDirectory(addon_handle) | |
# exit() | |
# | |
# xbmc.executebuiltin('ActivateWindow(busydialognocancel)') | |
# xbmc.executebuiltin('Play()') | |
args = sys.argv[2].split('&') | |
type = None | |
query = None | |
episode = None | |
season = None | |
tmdb_id = None | |
imdb_id = None | |
tvdb_id = None | |
year = None | |
xbmc.log(str(sys.argv[2])+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
for i in args: | |
if i[0:1] == '?': | |
i = i[1:] | |
# xbmc.log(str(i[0:1])+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
# xbmc.log(str(i[1:])+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
if 'type=' in i: | |
type = i.replace('type=','') | |
# xbmc.log(str(type)+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
if 'query=' in i: | |
query = i.replace('query=','') | |
# xbmc.log(str(query)+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
if 'episode=' in i: | |
episode = i.replace('episode=','') | |
# xbmc.log(str(episode)+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
if 'season=' in i: | |
season = i.replace('season=','') | |
# xbmc.log(str(season)+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
if 'year=' in i: | |
year = i.replace('year=','') | |
# xbmc.log(str(year)+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
if 'tmdb_id=' in i: | |
tmdb_id = i.replace('tmdb_id=','') | |
# xbmc.log(str(imdb_id)+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
if 'imdb_id=' in i: | |
imdb_id = i.replace('imdb_id=','') | |
# xbmc.log(str(imdb_id)+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
if 'tvdb_id=' in i: | |
imdb_id = i.replace('tvdb_id=','') | |
# xbmc.log(str(tvdb_id)+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
base = 'plugin://plugin.video.themoviedb.helper' | |
if type == 'episode': | |
if tmdb_id <> None: | |
url = '%s?info=play&tmdb_id=%s&type=episode&season=%s&episode=%s' % (base, tmdb_id, season, episode) | |
elif tvdb_id <> None: | |
url = '%s?info=play&tvdb_id=%s&type=episode&season=%s&episode=%s' % (base, tvdb_id, season, episode) | |
elif imdb_id <> None: | |
url = '%s?info=play&imdb_id=%s&type=episode&season=%s&episode=%s' % (base, imdb_id, season, episode) | |
elif query <> None: | |
url = '%s?info=play&query=%s&type=episode&season=%s&episode=%s' % (base, query, season, episode) | |
if type == 'movie': | |
if tmdb_id <> None: | |
url = '%s?info=play&tmdb_id=%s&type=movie' % (base, tmdb_id) | |
elif imdb_id <> None: | |
url = '%s?info=play&imdb_id=%s&type=movie' % (base, imdb_id) | |
if year <> None: | |
url = url + '&year=%s' % (base, movie_title, year) | |
xbmc.log(str(url)+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
# xbmc.executebuiltin('Dialog.Close(busydialognocancel)') | |
# xbmc.executebuiltin('Play(%s)' % url) | |
if os.path.exists('/home/osmc/' + sys.argv[2]): | |
xbmc.log('File Exists Exiting '+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
xbmcplugin.endOfDirectory(addon_handle) | |
exit() | |
if not os.path.exists('/home/osmc/' + sys.argv[2]): | |
f= open('/home/osmc/' + sys.argv[2],"w+") | |
xbmcplugin.endOfDirectory(addon_handle) | |
xbmc.executebuiltin('RunPlugin(%s)' % url) | |
# xbmcplugin.setResolvedUrl(addon_handle, True, xbmcgui.ListItem(path='')) | |
# xbmcplugin.endOfDirectory(addon_handle) | |
xbmc.log(str('While...')+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
while not 'Play with ' in xbmc.getInfoLabel('System.CurrentControl') or not 'Search ' in xbmc.getInfoLabel('System.CurrentControl'): | |
xbmc.sleep(1000) | |
xbmc.log(str(xbmc.getInfoLabel('System.CurrentControl'))+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
if 'Play with ' in xbmc.getInfoLabel('System.CurrentControl'): | |
break | |
if 'Search ' in xbmc.getInfoLabel('System.CurrentControl'): | |
break | |
xbmc.log(str('After While ')+'===>OPENMETA', level=xbmc.LOGNOTICE) | |
f.close | |
os.remove('/home/osmc/' + sys.argv[2]) | |
# try: | |
# f= open('/home/osmc/' + sys.argv[2],"w+") | |
# f.close | |
# except: | |
# pass | |
# try: | |
# | |
# except: | |
# pass | |
xbmc.executebuiltin('Dialog.Close(busydialognocancel)') | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment