Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# script.movielib

Readme kommt
6 changes: 3 additions & 3 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.movielib"
name="Movielib"
version="1.4.11"
version="1.5.11B"
provider-name="Regss">
<requires>
<import addon="xbmc.python" version="2.14.0" />
<import addon="xbmc.python" version="3.0.0" />
<import addon="script.module.pil" version="1.1.7" />
</requires>
<extension point="xbmc.python.script" library="default.py" />
Expand Down Expand Up @@ -34,4 +34,4 @@
<email>regss84@gmail.com</email>
<source>https://github.com/Regss/script.movielib</source>
</extension>
</addon>
</addon>
8 changes: 7 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[B]1.5.X BETA - has no sync in Kodi for urllib-Errors[/B]
- new User: me!
- Phytoncode upgraded from Version 2 to Version 3 with Phyton Script "2to3"
- Kodi intern Flags corrected
- Debug Code changed

[B]1.4.11[/B]
- sync trigger "on player stop" now sync only movie that stopped
- Fixed: allow to sync when server var POST_MAX_SIZE is set to 0
Expand Down Expand Up @@ -140,4 +146,4 @@
- Added: Sync Watched, LastPlayed, RecentlyAdded

[B]1.0.0[/B]
- Initial
- Initial
8 changes: 5 additions & 3 deletions resources/lib/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import xbmcaddon
import os
from PIL import Image
import cStringIO
from io import StringIO
from urllib.request import urlopen
import json
import urllib


__addon__ = xbmcaddon.Addon()
__addon_id__ = __addon__.getAddonInfo('id')
__datapath__ = xbmc.translatePath(os.path.join('special://profile/addon_data/', __addon_id__)).replace('\\', '/')
Expand Down Expand Up @@ -42,7 +44,7 @@ def create(source, i, width, height, q):
if file_path[8:12] == 'http':
try:
link = urllib.unquote(file_path[8:][:-1]).encode('utf-8')
file = cStringIO.StringIO(urllib.urlopen(link).read())
file = cStringIO.StringIO(urllib.request.urlopen(link).read())
except:
file = ''
else:
Expand Down Expand Up @@ -81,4 +83,4 @@ def create(source, i, width, height, q):
debug.debug(str(Error))

return output


4 changes: 2 additions & 2 deletions resources/lib/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def debug(msg):
xbmc.log('>>>> Movielib <<<< ' + msg, level=xbmc.LOGDEBUG)

def notice(msg):
xbmc.log('>>>> Movielib <<<< ' + msg, level=xbmc.LOGNOTICE)
xbmc.log('>>>> Movielib <<<< ' + msg, level=xbmc.LOGLOGNOTICE)

def notify(msg):
if 'true' in __addon__.getSetting('notify'):
xbmc.executebuiltin('Notification(Movielib, ' + msg + ', 4000, ' + __icon__ + ')')


53 changes: 50 additions & 3 deletions resources/lib/prepareValues.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import xbmcvfs
import os
import urllib2
import base64
import hashlib

import art
import debug

Expand Down Expand Up @@ -92,4 +90,53 @@ def prep(self, m, t):
values[q] = val[q]

debug.debug(str(values))
return values
return values
'runtime': str(m['runtime'] / 60) if 'runtime' in m else '',
'genre[]': panelsValue['genre'] if 'genre' in m else '',
'director[]': panelsValue['director'] if 'director' in m else '',
'originaltitle': m['originaltitle'].encode('utf-8') if 'originaltitle' in m else '',
'country[]': panelsValue['country'] if 'country' in m else '',
'set': m['set'].encode('utf-8') if 'set' in m else '',
'imdbid': m['imdbnumber'] if 'imdbnumber' in m else '',
'actor[]': panelsValue['actor'] if 'cast' in m else '',
'studio[]': panelsValue['studio'] if 'studio' in m else '',
'premiered': m['premiered'] if 'premiered' in m else '',
'episode': str(m['episode']) if 'episode' in m else '',
'season': str(m['season']) if 'season' in m else '',
'tvshow': str(m['tvshowid']) if 'tvshowid' in m else '',
'firstaired': m['firstaired'] if 'firstaired' in m else '',
'file': m['file'].replace('\\', '/').encode('utf-8') if 'file' in m else '',
'play_count': str(m['playcount']),
'last_played': m['lastplayed'],
'date_added': m['dateadded'],
'trailer': trailer,
'hash': hashlib.md5(str(m)).hexdigest()
}

# streamdetails
if 'streamdetails' in m:
stream = []
if len(m['streamdetails']['video']) > 0:
for s in m['streamdetails']['video']:
stream.append(';'.join(['v',s['codec'], str(s['aspect']), str(s['width']), str(s['height']), str(s['duration'] / 60), '', '', '', '']))

if len(m['streamdetails']['audio']) > 0:
for s in m['streamdetails']['audio']:
stream.append(';'.join(['a', '', '', '', '', '', s['codec'], str(s['channels']), s['language'], '']))

if len(m['streamdetails']['subtitle']) > 0:
for s in m['streamdetails']['subtitle']:
stream.append(';'.join(['s', '', '', '', '', '', '', '', '', s['language']]))

val.update({
'stream[]': stream
})

# add only values support for this video type
values = {}
for q in self.tn[t]['values']:
if q in val and len(val[q]) > 0:
values[q] = val[q]

debug.debug(str(values))
return values
12 changes: 6 additions & 6 deletions resources/lib/sendRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import xbmc
import xbmcaddon
import urllib
import urllib2
import urllib.request
import urllib.parse
import json
import time
import base64
Expand All @@ -23,7 +23,7 @@ def send(self, option, values=''):
debug.debug('[REQUEST]: ' + str(values))

# try send data
data = urllib.urlencode(values, True)
data = urllib.parse.urlencode(values, True)
data_len = len(data)

debug.debug('[REQUEST DATA SIZE]: ' + str(data_len) + ' bytes')
Expand All @@ -35,11 +35,11 @@ def send(self, option, values=''):

for l in range(1, 4):
try:
request = urllib2.Request(self.setXBMC['URL'] + option, data)
request = urllib.request.Request(self.setXBMC['URL'] + option, data)
if 'true' in self.setXBMC['Auth']:
base64string = base64.encodestring(self.setXBMC['AuthLogin'] + ':' + self.setXBMC['AuthPass']).replace('\n', '')
request.add_header('Authorization', 'Basic ' + base64string)
result = urllib2.urlopen(request)
result = urllib.request(request)
output = result.read()
except Exception as Error:
conn = False
Expand Down Expand Up @@ -73,4 +73,4 @@ def send(self, option, values=''):
return False

return output


2 changes: 1 addition & 1 deletion resources/lib/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,4 @@ def getDataFromXBMC(self, dataSORT):
debug.debug('[' + t + type.title() + 'XBMC]: ' + str(val))

return dataXBMC


89 changes: 88 additions & 1 deletion resources/lib/syncImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import xbmcaddon
import os
import urllib
import urllib2
import hashlib
import base64
from urllib.request import urlopen

__addon__ = xbmcaddon.Addon()
__addonname__ = __addon__.getAddonInfo('name')
Expand Down Expand Up @@ -106,6 +106,93 @@ def addImg(self, ImagesXBMC, ImagesToAdd, ImagesSORT):
if addedCount > 0:
debug.notify(__lang__(32104).encode('utf-8') + ' ' + __lang__(32121).encode('utf-8') + ' (' + __lang__(self.lang[type]).encode('utf-8') + ' - ' + __lang__(self.lang[img_type]).encode('utf-8') + '): ' + str(addedCount))

def removeImg(self, ImagesToRemove):
# removing images
toRemove = {}
removedCount = 0
for type, vals in ImagesToRemove.items():
for img_type, v in vals.items():
if len(v) > 0:
debug.debug('=== REMOVING ' + type.upper() + ' ' + img_type.upper() + ' IMAGES ===')
for file in v:
if 'poster' == img_type:
toRemove[removedCount] = type + '_' + str(file) + '.jpg'
if 'fanart' == img_type:
toRemove[removedCount] = type + '_' + str(file) + '_f.jpg'
if 'thumb' == img_type:
toRemove[removedCount] = 'actors/' + str(file) + '.jpg'
if 'exthumb' == img_type:
toRemove[removedCount] = type + '_' + str(file) + '.jpg'
removedCount += 1
toRemove[removedCount] = type + '_' + str(file) + 'm.jpg'
removedCount += 1
if len(toRemove) > 0:
if sendRequest.send(self, 'removeimages', toRemove) is False:
return False
debug.notify(__lang__(32105).encode('utf-8') + ' ' + __lang__(32121).encode('utf-8') + ': ' + str(removedCount))

ImagesToRemove = {}
for v_type in ImagesXBMC.keys():
ImagesToRemove[v_type] = {}
for img_type in ImagesXBMC[v_type].keys():
ImagesToRemove[v_type][img_type] = set(ImagesSite[v_type][img_type]) - set(ImagesXBMC[v_type][img_type].keys())
debug.debug('[ImagesToRemove]: ' + str(ImagesToRemove))
removeImg(self, ImagesToRemove)

# update hash
value = { 'images': str(hashImagesXBMC) }
if sendRequest.send(self, 'updatehash', value) is False:
return False

def addImg(self, ImagesXBMC, ImagesToAdd, ImagesSORT):
# adding new images
for type in ImagesSORT['images']:

for img_type in ImagesSORT[type]:

if len(ImagesToAdd[type][img_type]) > 0:
debug.debug('=== ADDING ' + type.upper() + ' ' + img_type.upper() + ' IMAGES ===')

countToAdd = len(ImagesToAdd[type][img_type])
addedCount = 0
self.progBar.create(__lang__(32200), __addonname__ + ', ' + __lang__(32204) + ' ' + __lang__(32121) + ' (' + __lang__(self.lang[type]) + ' - ' + __lang__(self.lang[img_type]) + ')')

for id in ImagesToAdd[type][img_type]:
# progress bar update
p = int((float(100) / float(countToAdd)) * float(addedCount))
self.progBar.update(p, str(addedCount + 1) + '/' + str(countToAdd) + ' - ' + self.namesXBMC[type][id])

if 'poster' == img_type and 'episodes' in type:
t = art.create(ImagesXBMC[type][img_type][id], 'p', 200, 113, 70)
if 'poster' == img_type and 'episodes' not in type:
t = art.create(ImagesXBMC[type][img_type][id], 'p', 200, 294, 70)
if 'fanart' == img_type:
t = art.create(ImagesXBMC[type][img_type][id], 'f', 1280, 720, 70)
if 'thumb' == img_type:
t = art.create(ImagesXBMC[type][img_type][id], 'a', 75, 100, 70)
if 'exthumb' == img_type:
ex_size = self.setSITE['xbmc_exthumbs_q'].split('x')
t = art.create('image://' + urllib.quote_plus(ImagesXBMC[type][img_type][id].encode('utf-8')) + '/', 'e', int(ex_size[0]), int(ex_size[1]), 70)

if len(t) > 0:
if 'actors' in type:
name = 'actors/' + str(id) + '.jpg'
else:
f = '_f' if 'fanart' in img_type else ''
name = type + '_' + str(id) + f + '.jpg'
value = {
'name': name,
'img': base64.b64encode(t)
}
if sendRequest.send(self, 'addimages', value) is False:
self.progBar.close()
return False
addedCount += 1
self.progBar.close()

if addedCount > 0:
debug.notify(__lang__(32104).encode('utf-8') + ' ' + __lang__(32121).encode('utf-8') + ' (' + __lang__(self.lang[type]).encode('utf-8') + ' - ' + __lang__(self.lang[img_type]).encode('utf-8') + '): ' + str(addedCount))

def removeImg(self, ImagesToRemove):
# removing images
toRemove = {}
Expand Down
12 changes: 6 additions & 6 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ def __init__(self):

# start Movielib on KODI start
if 'true' in __addon__.getSetting('OnStart'):
xbmc.executebuiltin('XBMC.RunScript(' + __addon_id__ + ', 1)')
xbmc.executebuiltin('RunScript(' + __addon_id__ + ', 1)')

def onNotification(self, sender, method, data):
data = json.loads(data)
# start Movielib for update banner (Now Playing)
if method == 'Player.OnPlay':
if 'item' in data and 'type' in data['item'] and 'id' in data['item']:
xbmc.executebuiltin('XBMC.RunScript(' + __addon_id__ + ', 2, ' + str(data['item']['id']) + ', ' + data['item']['type'] + ')')
xbmc.executebuiltin('RunScript(' + __addon_id__ + ', 2, ' + str(data['item']['id']) + ', ' + data['item']['type'] + ')')

# start Movielib on trigger
if method in __trigger__.keys() and 'true' in __trigger__[method]:
if method == 'Player.OnStop':
if 'item' in data and 'type' in data['item'] and 'id' in data['item']:
xbmc.executebuiltin('XBMC.RunScript(' + __addon_id__ + ', 3, ' + str(data['item']['id']) + ', ' + data['item']['type'] + ')')
xbmc.executebuiltin('RunScript(' + __addon_id__ + ', 3, ' + str(data['item']['id']) + ', ' + data['item']['type'] + ')')
else:
xbmc.executebuiltin('XBMC.RunScript(' + __addon_id__ + ', 1)')
xbmc.executebuiltin('RunScript(' + __addon_id__ + ', 1)')

monitor = Monitor()

while(not xbmc.abortRequested):
while(not xbmc.Monitor().abortRequested()):
xbmc.sleep(100)