Skip to content

Commit

Permalink
[script.copacetic.helper] 1.1.6 (#2637)
Browse files Browse the repository at this point in the history
Squashed with
script.copacetic.helper-1.1.5
  • Loading branch information
realcopacetic authored Sep 12, 2024
1 parent a98850c commit cf3d51b
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 107 deletions.
19 changes: 19 additions & 0 deletions script.copacetic.helper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ All code contained in this project is licensed under GPL 3.0.
* __jurialmunkey__ for all the best-practice code examples from [plugin.video.themoviedb.helper](https://github.com/jurialmunkey/plugin.video.themoviedb.helper) and forum support.

### Changelog
---
**1.1.6**
- Added missing PVR windows to background monitor expression

**1.1.5**
- Fixed bug in actor_credits() where the current infoscreen item was not being removed from the 'More from X' actor credits widget if the infoscreen was for an episode, because it was expecting to find the TV show title in ListItem.Label and instead receiving the episode name, which wouldn't ever match.

**1.1.4**
- Fixed bug with infoscreen widgets not updating when navigating between infoscreens by ensuring director and genre properties update each time the infoscreen is loaded, even if the underlying list hasn't been scrolled
- Added season info monitoring
- Added a window property that is set to true while set progress is being calculated in get_collection_status()

**1.1.3**
- Fixed conditional that was preventing cropped clearlogo paths from being fetched for home widgets

**.1.1.2**
- Support for more edge case conversions of different image modes in clearlogo_cropper().
- Added method to service monitor to calculate watched percentage of sets and return as a property

**.1.1.1**
- Fixed bug in previous version causing dark cropped clearlogos to always be served in certain scenarios

Expand Down
2 changes: 1 addition & 1 deletion script.copacetic.helper/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<addon id="script.copacetic.helper" name="Copacetic Helper" version="1.1.1" provider-name="realcopacetic">
<addon id="script.copacetic.helper" name="Copacetic Helper" version="1.1.6" provider-name="realcopacetic">
<requires>
<import addon="xbmc.python" version="3.0.1" />
<import addon="script.module.pil" version="5.1.0" />
Expand Down
15 changes: 10 additions & 5 deletions script.copacetic.helper/resources/lib/plugin/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from resources.lib.plugin.json_map import JSON_MAP
from resources.lib.plugin.library import *
from resources.lib.utilities import (ADDON, infolabel, json_call, log,
from resources.lib.utilities import (ADDON, condition, infolabel, json_call, log,
set_plugincontent)


Expand Down Expand Up @@ -224,8 +224,12 @@ def director_credits(self):

def actor_credits(self):
filters = [self.filter_actor]
current_item = infolabel('ListItem.Label')

# grab current movie or tvshow name
if condition('String.IsEqual(ListItem.DBType,episode)'):
current_item = infolabel('ListItem.TVShowTitle')
else:
current_item = infolabel('ListItem.Label')
# json lookup for movies and tvshows by given actor
movies_json_query = json_call('VideoLibrary.GetMovies',
properties=JSON_MAP['movie_properties'],
sort=self.sort_year,
Expand All @@ -239,10 +243,11 @@ def actor_credits(self):
query_filter={'and': filters},
parent='actor_credits'
)

# work out combined number of movie/tvshow credits
total_items = int(movies_json_query['result']['limits']['total']) + int(
tvshows_json_query['result']['limits']['total'])

# if there are movie results, remove the current item if it is in the list, then add the remaining to the plugin directory
try:
movies_json_query = movies_json_query['result']['movies']
except Exception:
Expand All @@ -253,7 +258,7 @@ def actor_credits(self):
movies_json_query.remove(
dict_to_remove) if dict_to_remove is not None and total_items > 1 else None
add_items(self.li, movies_json_query, type='movie')

# if there are tvshow results, remove the current item if it is in the list, then add the remaining to the plugin directory
try:
tvshows_json_query = tvshows_json_query['result']['tvshows']
except Exception:
Expand Down
33 changes: 33 additions & 0 deletions script.copacetic.helper/resources/lib/script/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,39 @@ def dialog_yesno(heading, message, **kwargs):
log_and_execute(action)


def get_collection_status(dbid, **kwargs):
window_property('collection_watched_calculating', set='true')
watched = 0
query = json_call(
'VideoLibrary.GetMovieSetDetails',
params={'setid': int(dbid)},
parent='get_set_movies'
)
try:
total = query['result']['setdetails']['limits']['total']
movies = query['result']['setdetails']['movies']
except KeyError:
return
else:
for movie in movies:
query = json_call(
'VideoLibrary.GetMovieDetails',
params={'properties': [
'playcount'], 'movieid': movie['movieid']},
parent='get_movie_playcounts'
)
playcount = query['result']['moviedetails'].get('playcount')
if playcount:
watched += 1
finally:
# https://stackoverflow.com/a/68118106/21112145
percentage = (total and watched / total or 0) * 100
unwatched = total - watched
window_property('collection_watched_calculating', clear=True)
window_property('collection_watched_dbid', set=dbid)
window_property('collection_watched_percentage', set=percentage)
window_property('collection_unwatched', set=unwatched)

def globalsearch_input(**kwargs):
kb = xbmc.Keyboard(
infolabel('$INFO[Skin.String(globalsearch)]'), infolabel('$LOCALIZE[137]'))
Expand Down
9 changes: 4 additions & 5 deletions script.copacetic.helper/resources/lib/service/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ def crop_image(self, url):
log(
f'ImageEditor: Error - could not open cached image --> {error}', force=True)
else:
if image.mode == 'LA': # Convert if mode == 'LA'
converted_image = Image.new("RGBA", image.size)
converted_image.paste(image)
image = converted_image
converted_image = Image.new("RGBA", image.size)
converted_image.paste(image)
image = converted_image
try:
image = image.crop(image.convert('RGBa').getbbox())
except ValueError as error:
Expand Down Expand Up @@ -418,7 +417,7 @@ def _set_art(self, key, items):
clearlogo = art.get('clearlogo-billboard', False)
if not clearlogo:
clearlogo = art.get('clearlogo', False)
if clearlogo and condition('!Skin.HasSetting(Experiment_Disable_Transitions)'):
if clearlogo and condition('!Skin.HasSetting(Quick_Transitions)'):
clearlogo = url_decode_path(clearlogo)
clearlogo = self._crop_clearlogo(clearlogo)
window_property(f'{key}_clearlogo', set=clearlogo)
Expand Down
Loading

0 comments on commit cf3d51b

Please sign in to comment.