Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stash 0.24 fixes #21

Closed
wants to merge 2 commits into from
Closed
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
12 changes: 7 additions & 5 deletions resources/lib/criterion_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
def parse(criterions):
filter = {}

for criterion in criterions:
if criterion in ('sceneIsMissing', 'imageIsMissing', 'performerIsMissing', 'galleryIsMissing', 'tagIsMissing', 'studioIsMissing', 'studioIsMissing'):
filter['is_missing'] = criterion['value']
for name, criterion in criterions.items():
if name in ('is_missing', 'has_markers'):
filter[name] = criterion['value']
elif name in ('organized', 'performer_favorite', 'interactive'):
filter[name] = criterion['value'] == 'true'
else:
is_timestamp_field = criterion in ('created_at', 'updated_at', 'scene_created_at', 'scene_updated_at')
is_timestamp_field = name in ('created_at', 'updated_at', 'scene_created_at', 'scene_updated_at')
value_transformer = (lambda v: v.replace(' ', 'T') if isinstance(v, str) else v) if is_timestamp_field else lambda v: v
filter[criterion] = parse_criterion(criterions[criterion], value_transformer)
filter[name] = parse_criterion(criterion, value_transformer)

return filter

Expand Down
15 changes: 8 additions & 7 deletions resources/lib/listing/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ def _create_items(self, criterion: dict, sort_field: str, sort_dir: int, params:
def _create_item(self, scene: dict, **kwargs):
title = kwargs['title'] if 'title' in kwargs else scene['title']
screenshot = kwargs['screenshot'] if 'screenshot' in kwargs else scene['paths']['screenshot']
# * 2 because rating is 1 to 5 and Kodi uses 1 to 10
rating = scene['rating'] * 2 if 'rating' in scene and scene['rating'] is not None else 0
duration = int(scene['file']['duration'])
file = scene['files'][0]
# / 10 because rating is 1 to 100 and Kodi uses 1 to 10
rating = round(scene['rating100'] / 10 if 'rating100' in scene and scene['rating100'] is not None else 0)
duration = int(file['duration'])
item = xbmcgui.ListItem(label=title)
item.setInfo('video', {'title': title,
'mediatype': 'video',
Expand All @@ -92,12 +93,12 @@ def _create_item(self, scene: dict, **kwargs):
'dateadded': scene['created_at']
})

item.addStreamInfo('video', {'codec': scene['file']['video_codec'],
'width': scene['file']['width'],
'height': scene['file']['height'],
item.addStreamInfo('video', {'codec': file['video_codec'],
'width': file['width'],
'height': file['height'],
'duration': duration})

item.addStreamInfo('audio', {'codec': scene['file']['audio_codec']})
item.addStreamInfo('audio', {'codec': file['audio_codec']})

screenshot = self._client.add_api_key(screenshot)
item.setArt({'thumb': screenshot, 'fanart': screenshot})
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/listing/scene_marker_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _create_items(self, criterion: dict, sort_field: str, sort_dir: int, params:
item = self._create_item(marker['scene'], title=title, screenshot=marker['screenshot'])
url = self._create_play_url(marker['scene']['id'])

duration = marker['scene']['file']['duration']
duration = marker['scene']['files'][0]['duration']
item.setProperty('StartPercent', str(round(marker['seconds'] / duration * 100, 2)))

items.append((item, url))
Expand Down
16 changes: 8 additions & 8 deletions resources/lib/stash_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ def find_scenes(self, scene_filter=None, sort_field='title', sort_dir='asc'):
id
title
details
rating
rating100
date
created_at
paths {
screenshot
}
file {
files {
duration
video_codec
audio_codec
Expand Down Expand Up @@ -101,14 +101,14 @@ def find_scene(self, id):
id
title
details
rating
rating100
date
created_at
paths {
stream
screenshot
}
file {
files {
duration
video_codec
audio_codec
Expand All @@ -133,13 +133,13 @@ def find_scene(self, id):
id
title
details
rating
rating100
date
created_at
paths {
screenshot
}
file {
files {
duration
video_codec
audio_codec
Expand Down Expand Up @@ -283,13 +283,13 @@ def find_scene_markers(self, markers_filter=None, sort_field='title', sort_dir=0
id
title
details
rating
rating100
date
created_at
paths {
screenshot
}
file {
files {
duration
video_codec
audio_codec
Expand Down
Loading