BlenderKit: fix poll functions for rating and fast metadata edit
HDR - use wide image format Switch to use of asset thumbnails for asset instead of file thumbnails.
This commit is contained in:
parent
ebe76f3a7b
commit
63492d3d03
|
@ -56,6 +56,7 @@ if "bpy" in locals():
|
|||
ui_bgl = reload(ui_bgl)
|
||||
ui_panels = reload(ui_panels)
|
||||
upload = reload(upload)
|
||||
upload_bg = reload(upload_bg)
|
||||
utils = reload(utils)
|
||||
|
||||
bl_ui_label = reload(bl_ui_label)
|
||||
|
@ -90,6 +91,7 @@ else:
|
|||
from blenderkit import ui_bgl
|
||||
from blenderkit import ui_panels
|
||||
from blenderkit import upload
|
||||
from blenderkit import upload_bg
|
||||
from blenderkit import utils
|
||||
|
||||
from blenderkit.bl_ui_widgets import bl_ui_label
|
||||
|
|
|
@ -809,6 +809,7 @@ class Downloader(threading.Thread):
|
|||
t = '%iKB' % fskb
|
||||
else:
|
||||
t = ' %iMB' % fsmb
|
||||
|
||||
tcom.report = f'Downloading {t} {self.resolution}'
|
||||
|
||||
dl = 0
|
||||
|
|
|
@ -392,9 +392,9 @@ class FastRateMenu(Operator):
|
|||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
# scene = bpy.context.scene
|
||||
# ui_props = scene.blenderkitUI
|
||||
return True # ui_props.active_index > -1
|
||||
scene = bpy.context.scene
|
||||
ui_props = scene.blenderkitUI
|
||||
return ui_props.active_index > -1
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
|
|
@ -243,21 +243,37 @@ def parse_result(r):
|
|||
r['available_resolutions'] = []
|
||||
allthumbs = []
|
||||
durl, tname, small_tname = '', '', ''
|
||||
for f in r['files']:
|
||||
if f['fileType'] == 'thumbnail':
|
||||
tname = paths.extract_filename_from_url(f['fileThumbnailLarge'])
|
||||
small_tname = paths.extract_filename_from_url(f['fileThumbnail'])
|
||||
allthumbs.append(tname) # TODO just first thumb is used now.
|
||||
|
||||
tdict = {}
|
||||
for i, t in enumerate(allthumbs):
|
||||
tdict['thumbnail_%i'] = t
|
||||
if r['assetType'] == 'hdr':
|
||||
tname = paths.extract_filename_from_url(r['thumbnailMiddleUrlNonsquared'])
|
||||
else:
|
||||
tname = paths.extract_filename_from_url(r['thumbnailMiddleUrl'])
|
||||
small_tname = paths.extract_filename_from_url(r['thumbnailSmallUrl'])
|
||||
allthumbs.append(tname) # TODO just first thumb is used now.
|
||||
# if r['fileType'] == 'thumbnail':
|
||||
# tname = paths.extract_filename_from_url(f['fileThumbnailLarge'])
|
||||
# small_tname = paths.extract_filename_from_url(f['fileThumbnail'])
|
||||
# allthumbs.append(tname) # TODO just first thumb is used now.
|
||||
|
||||
for f in r['files']:
|
||||
# if f['fileType'] == 'thumbnail':
|
||||
# tname = paths.extract_filename_from_url(f['fileThumbnailLarge'])
|
||||
# small_tname = paths.extract_filename_from_url(f['fileThumbnail'])
|
||||
# allthumbs.append(tname) # TODO just first thumb is used now.
|
||||
|
||||
|
||||
if f['fileType'] == 'blend':
|
||||
durl = f['downloadUrl'].split('?')[0]
|
||||
# fname = paths.extract_filename_from_url(f['filePath'])
|
||||
|
||||
if f['fileType'].find('resolution') > -1:
|
||||
r['available_resolutions'].append(resolutions.resolutions[f['fileType']])
|
||||
|
||||
#code for more thumbnails
|
||||
# tdict = {}
|
||||
# for i, t in enumerate(allthumbs):
|
||||
# tdict['thumbnail_%i'] = t
|
||||
|
||||
r['max_resolution'] = 0
|
||||
if r['available_resolutions']: # should check only for non-empty sequences
|
||||
r['max_resolution'] = max(r['available_resolutions'])
|
||||
|
@ -311,7 +327,7 @@ def parse_result(r):
|
|||
if asset_type == 'material':
|
||||
asset_data['texture_size_meters'] = params.get('textureSizeMeters', 1.0)
|
||||
|
||||
asset_data.update(tdict)
|
||||
# asset_data.update(tdict)
|
||||
|
||||
au = scene.get('assets used', {})
|
||||
if au == {}:
|
||||
|
@ -1019,25 +1035,44 @@ class Searcher(threading.Thread):
|
|||
thumb_full_filepaths = []
|
||||
# END OF PARSING
|
||||
for d in rdata.get('results', []):
|
||||
thumb_small_urls.append(d["thumbnailSmallUrl"])
|
||||
imgname = paths.extract_filename_from_url(d['thumbnailSmallUrl'])
|
||||
imgpath = os.path.join(self.tempdir, imgname)
|
||||
thumb_small_filepaths.append(imgpath)
|
||||
|
||||
for f in d['files']:
|
||||
# TODO move validation of published assets to server, too manmy checks here.
|
||||
if f['fileType'] == 'thumbnail' and f['fileThumbnail'] != None and f['fileThumbnailLarge'] != None:
|
||||
if f['fileThumbnail'] == None:
|
||||
f['fileThumbnail'] = 'NONE'
|
||||
if f['fileThumbnailLarge'] == None:
|
||||
f['fileThumbnailLarge'] = 'NONE'
|
||||
|
||||
thumb_small_urls.append(f['fileThumbnail'])
|
||||
thumb_full_urls.append(f['fileThumbnailLarge'])
|
||||
|
||||
imgname = paths.extract_filename_from_url(f['fileThumbnail'])
|
||||
imgpath = os.path.join(self.tempdir, imgname)
|
||||
thumb_small_filepaths.append(imgpath)
|
||||
if d["assetType"] == 'hdr':
|
||||
larege_thumb_url = d['thumbnailMiddleUrlNonsquared']
|
||||
|
||||
imgname = paths.extract_filename_from_url(f['fileThumbnailLarge'])
|
||||
imgpath = os.path.join(self.tempdir, imgname)
|
||||
thumb_full_filepaths.append(imgpath)
|
||||
else:
|
||||
larege_thumb_url = d['thumbnailMiddleUrl']
|
||||
|
||||
thumb_full_urls.append(larege_thumb_url)
|
||||
imgname = paths.extract_filename_from_url(larege_thumb_url)
|
||||
imgpath = os.path.join(self.tempdir, imgname)
|
||||
thumb_full_filepaths.append(imgpath)
|
||||
|
||||
|
||||
|
||||
# for f in d['files']:
|
||||
# # TODO move validation of published assets to server, too manmy checks here.
|
||||
# if f['fileType'] == 'thumbnail' and f['fileThumbnail'] != None and f['fileThumbnailLarge'] != None:
|
||||
# if f['fileThumbnail'] == None:
|
||||
# f['fileThumbnail'] = 'NONE'
|
||||
# if f['fileThumbnailLarge'] == None:
|
||||
# f['fileThumbnailLarge'] = 'NONE'
|
||||
#
|
||||
# thumb_small_urls.append(f['fileThumbnail'])
|
||||
# thumb_full_urls.append(f['fileThumbnailLarge'])
|
||||
#
|
||||
# imgname = paths.extract_filename_from_url(f['fileThumbnail'])
|
||||
# imgpath = os.path.join(self.tempdir, imgname)
|
||||
# thumb_small_filepaths.append(imgpath)
|
||||
#
|
||||
# imgname = paths.extract_filename_from_url(f['fileThumbnailLarge'])
|
||||
# imgpath = os.path.join(self.tempdir, imgname)
|
||||
# thumb_full_filepaths.append(imgpath)
|
||||
|
||||
sml_thbs = zip(thumb_small_filepaths, thumb_small_urls)
|
||||
full_thbs = zip(thumb_full_filepaths, thumb_full_urls)
|
||||
|
|
|
@ -710,6 +710,8 @@ def get_large_thumbnail_image(asset_data):
|
|||
iname = utils.previmg_name(ui_props.active_index, fullsize=True)
|
||||
directory = paths.get_temp_dir('%s_search' % mappingdict[ui_props.asset_type])
|
||||
tpath = os.path.join(directory, asset_data['thumbnail'])
|
||||
if asset_data['assetType'] == 'hdr':
|
||||
tpath = os.path.join(directory, asset_data['thumbnail'])
|
||||
if not asset_data['thumbnail']:
|
||||
tpath = paths.get_addon_thumbnail_path('thumbnail_not_available.jpg')
|
||||
|
||||
|
|
|
@ -569,7 +569,8 @@ def update_free_full(self, context):
|
|||
|
||||
|
||||
def can_edit_asset(active_index=-1, asset_data=None):
|
||||
if active_index == -1 and not asset_data:
|
||||
print(active_index, asset_data)
|
||||
if active_index < 0 and not asset_data:
|
||||
return False
|
||||
profile = bpy.context.window_manager.get('bkit profile')
|
||||
if profile is None:
|
||||
|
|
Loading…
Reference in New Issue