Hello, I hope I can get some help with this.
I’m working with this naming convention FOO_005_019 and it’s an mp4 so it’s like FOO_005_019.mp4
When I try to validate I get this error :
Traceback (most recent call last):
File "C:\Program Files\Shotgun\Resources\Desktop\Python\bundle_cache\app_store\tk-multi-publish2\v2.6.4\python\tk_multi_publish2\api\plugins\publish_plugin_instance.py", line 308, in _handle_plugin_error
yield
File "C:\Program Files\Shotgun\Resources\Desktop\Python\bundle_cache\app_store\tk-multi-publish2\v2.6.4\python\tk_multi_publish2\api\plugins\publish_plugin_instance.py", line 180, in run_validate
status = self._hook_instance.validate(settings, item)
File "C:\Users\sreyeeshgarimella\AppData\Roaming\Shotgun\bundle_cache\sg\kavaleer.shotgrid.autodesk.com\v9086\hooks\tk-multi-publish2\standalone\upload_version.py", line 29, in validate
raise Exception(error_msg)
Exception: Can not find episode with code 019 on Shotgrid.
Please make an episode in Shotgrid for this code, following the naming conventions:
###_Episode_Name.
Here is my code :
# std lib imports
import re
import os
# third party imports
import sgtk
HookBaseClass = sgtk.get_hook_baseclass()
class UploadVersionPlugin(HookBaseClass):
def validate(self, settings, item):
current_engine = sgtk.platform.current_engine()
tk = current_engine.sgtk
folder_name = os.path.basename(item.properties['__collected_file_path__'])
episode_code = re.findall(r"\d{3}", folder_name)[1]
episode = tk.shotgun.find_one('Episode', [['project', 'is', {'type': 'Project', 'id': 122}], ['code', 'contains', episode_code]])
if not episode:
error_msg = (
f"Can not find episode with code {episode_code} on Shotgrid. \n"
f"Please make an episode in Shotgrid for this code, following the naming conventions: \n"
f"###_Episode_Name."
)
self.logger.error(error_msg)
raise Exception(error_msg)
return super(UploadVersionPlugin, self).validate(settings, item)
def publish(self, settings, item):
super(UploadVersionPlugin, self).publish(settings, item)
# versions do not need to be reviewed if they come from episode pack
# check if item is from episode folder
is_lam_episode_folder = re.match(
r'^FOO_\d{3}_.+',
os.path.basename(item.properties['__collected_file_path__'])
)
# only continue is item is from episode folder
if not is_lam_episode_folder:
return
version_id = item.properties['sg_version_data']['id']
tk = sgtk.sgtk_from_entity('Version', version_id)
data = {
'sg_status_list': 'na',
'sg_artist_status': 'na',
'sg_lead_status': 'na',
'sg_aad_status': 'na',
'sg_animation_director_status': 'na',
'sg_offshore_director_status': 'na',
'sg_kav_producer_status': 'na',
'sg_client_status': 'na'
}
tk.shotgun.update('Version', version_id, data)
Is the error pointing to this code ?