def load_client(self, project_name): """ Attributes ---------- project_name : str A string representing the name of the Frame.io project you wish to upload your files to. """ client = FrameioClient( os.getenv("FRAMEIO_TOKEN") ) # This won't work unless you have a .env file with the correct token. me = client.get_me() teams = client.get_all_teams(account_id=me['account_id']) selected_team_id = teams.results[0]['id'] projects = client.get_projects( team_id=selected_team_id ) # Make sure that you're selecting correct team via the index value [0] or [1] # Create a dict of project names and ids project_dict = dict() project_names_list = list() for project in projects.results: project_dict[project['name']] = project['id'] project_names_list.append(project['name']) # Extract the matching one matching_name = process.extractOne(project_name, project_names_list)[0] print(f"Matched to project: {matching_name}") project_id = project_dict[ matching_name] # Gets relevant value for matched key self.project_id = project_id print(f"Project ID set to: {self.project_id}") self.client = client
def benchmark(asset_id): token = os.getenv("FRAMEIO_TOKEN") client = FrameioClient(token) asset_info = client.assets.get(asset_id) accelerated_filename = client.download(asset_info, "downloads", prefix="accelerated_", multi_part=True, concurrency=20)
def download(asset_id): token = getenv("FRAME_IO_TOKEN") client = FrameioClient(token) asset_info = client.get_asset(asset_id) filename = client.download(asset_info, "", prefix="", multi_part=True, concurrency=8) return filename
def init_client(): if len(token) < 5: print("Bad token, exiting test.") sys.exit(1) if environment == "PRODUCTION": client = FrameioClient(token) print("Client connection initialized.") else: client = FrameioClient(token, host='https://api.dev.frame.io') print("Client connection initialized.") return client
def main(): client = FrameioClient("TOKEN") filesize = os.path.getsize('demo.mov') asset = client.create_asset( parent_asset_id="PARENT_ASSET_ID", name="Test123.mov", type="file", filetype="video/quicktime", filesize=filesize ) file = open("demo.mov", "rb") client.upload(asset, file)
def invite_users(): token = os.getenv('FRAMEIO_TOKEN') client = FrameioClient(token) user_list = ["*****@*****.**", "*****@*****.**"] client.teams.add_members('team_id', user_list)
def manage_users(): token = os.getenv("FRAMEIO_TOKEN") team_id = "35543cd2-954a-c6ee-4aa1-ce9e19602aa9" users_list = ["*****@*****.**", "*****@*****.**"] client = FrameioClient(token) client.teams.add_members(team_id, users_list) client.teams.remove_members(team_id, users_list)
def init_client(): if len(token) < 5: print("Bad token, exiting test.") sys.exit(1) client = FrameioClient(token) print("Client connection initialized.") return client
def fio_client(profile=None): profile = profile or fioconf.fetch("profiles", "default") or "default" token = fioconf.fetch(profile, "bearer_token") host = fioconf.fetch(profile, "host") or "https://api.frame.io" if "http://" in host: click.echo( "Please specify a host using HTTPS, this will not work with HTTP. Exiting..." ) time.sleep(1) sys.exit(1) return FrameioClient(token, host=host)
def __init__(self): """Auto executed upon instantiation""" super(ShotIO, self).__init__() #load_dotenv() self.location = os.path.dirname(os.path.realpath(__file__)) self.__load_env() if self.__fio_token is None: print( 'I was unable to get a Frame.io Token from your .env file or your environment variables' ) thing = input( 'Please paste it here or edit the .env file located at') self.__write_env('FRAME_IO_TOKEN', thing) self.__load_env() self.fio = FrameioClient(self.__fio_token) self.sg = shotgun_api3.Shotgun(self.sg_url, login=self.sg_user, password=self.__sg_pass)
f_csv.writerows(flat_assets_list) return if __name__ == '__main__': TOKEN = os.getenv('FRAME_IO_TOKEN') if os.environ.get('FRAME_IO_TOKEN') == None: raise ClientNotTokenized( 'The Python SDK requires a valid developer token.') ROOT_ASSET_ID = os.getenv('ROOT_ASSET_ID') if os.environ.get('ROOT_ASSET_ID') == None: raise RootAssetIDNotFound( 'If you don\'t know what Root Asset ID is, read this guide: https://docs.frame.io/docs/root-asset-ids' ) # Initialize the client library client = FrameioClient(TOKEN) # Gather all assets in the account projects = get_projects_from_account(client) assets_in_account = scrape_asset_data_from_projects(client, projects) # Pass a filename to the .csv writer so we can explicitly ID the file acct = client.get_me() acct_id = acct['account_id'] filename = 'assets_for_account_id-{}.csv'.format(acct_id) # Write the .csv write_assets_to_csv(assets_in_account, filename)
def frameioclient(token): return FrameioClient("aaaabbbbccccddddeeee")
flat_comments_list = [] for c in c_list: flat_comments_list.append(flatten_dict(c)) with open('comments.csv', 'w') as file: f_csv = csv.DictWriter(file, headers, extrasaction='ignore') f_csv.writeheader() f_csv.writerows(flat_comments_list) if __name__ == '__main__': TOKEN = os.getenv('FRAME_IO_TOKEN') if os.environ.get('FRAME_IO_TOKEN') == None: raise ClientNotTokenized( 'The Python SDK requires a valid developer token.') ROOT_ASSET_ID = os.getenv('ROOT_ASSET_ID') if os.environ.get('ROOT_ASSET_ID') == None: raise RootAssetIDNotFound( 'If you don\'t know what Root Asset ID is, read this guide: https://docs.frame.io/docs/root-asset-ids' ) # Initialize the client library client = FrameioClient(TOKEN) # Build the comments list comments = [] comments_list = build_comments_list(client, ROOT_ASSET_ID, comments) # Write the comments to comments.csv write_comments_csv(comments_list)
def get_team_list(account_id): token = os.getenv('FRAMEIO_TOKEN') client = FrameioClient(token) return client.teams.list_all('account_id')
def main(): TOKEN = os.getenv("FRAME_IO_TOKEN") client = FrameioClient(TOKEN) me = client.get_me() print(me['id'])
def main(): client = FrameioClient("TOKEN") file_path = './file_to_upload.mov' parent_asset_id = '' asset = client.assets.upload(parent_asset_id,file_path)
class ShotIO(object): """ShotIO Class definition""" def __init__(self): """Auto executed upon instantiation""" super(ShotIO, self).__init__() #load_dotenv() self.location = os.path.dirname(os.path.realpath(__file__)) self.__load_env() if self.__fio_token is None: print( 'I was unable to get a Frame.io Token from your .env file or your environment variables' ) thing = input( 'Please paste it here or edit the .env file located at') self.__write_env('FRAME_IO_TOKEN', thing) self.__load_env() self.fio = FrameioClient(self.__fio_token) self.sg = shotgun_api3.Shotgun(self.sg_url, login=self.sg_user, password=self.__sg_pass) def __write_env(self, key, value): with open(self.location + '\\.env', 'a') as f: f.write(key + '=' + value + '\n') def __load_env(self): try: with open(self.location + '\\.env', 'r') as env: vars_dict = dict( tuple(line.replace("\n", '').split('=')) for line in env.readlines() if not line.startswith('#')) os.environ.update(vars_dict) self.__fio_token = os.environ.get( 'FRAME_IO_TOKEN') or os.environ.get('FIO_TOKEN') self.sg_url = os.environ.get('SG_URL') self.sg_user = os.environ.get('SG_USER') self.__sg_pass = os.environ.get('SG_PASS') except FileNotFoundError: self.__survey() except Exception as e: print('Error related to the .env file') raise e # Could not read env file def __input(self, question): #error_stack = 0 while True: try: response = input(question) if (response): return response except ValueError: print("Sorry, I didn't understand that." ) # User entered something unintelligible to the CLI continue def __getpass(self, question): #error_stack = 0 while True: try: response = getpass.getpass(prompt=question) if (response): return response except ValueError: print("Sorry, I didn't understand that, please try again." ) # User entered something unintelligible to the CLI continue def __survey(self): print("I was unable to locate the .env file at " + self.location + "\\.env") if ((input("Would you like to create a .env file now? [Y] / [n]") or 'y').lower() == 'y'): fio_token = self.__input("Please enter your Frame.io token: ") self.__write_env('FRAME_IO_TOKEN', fio_token) sg_url = self.__input( "Please enter your Shotgun url (e.g. https://subdomain.shotgunstudio.com): " ) self.__write_env('SG_URL', sg_url) sg_user = self.__input("Please enter your Shotgun username: "******"Please enter your Shotgun password (hidden): ") self.__write_env('SG_PASS', sg_pass) self.__load_env() print("Entered all parameters ") else: sys.exit( "Exiting program, missing required environment variables.") def getTeamsFromAccount(self, client): """ Builds a list of teams for the account. """ acct = client.get_me() acct_id = acct['account_id'] return client.get_teams(acct_id) def getProjectsFromTeam(self, client, team): """Returns a list of projects for a team.""" projects_in_team = [] data = client.get_projects(team.get('id')) team_name = team.get('name') for proj in data: proj['project_name'] = proj.get('name') proj['team_name'] = team_name projects_in_team.append(proj) return projects_in_team def getProjectsFromAccount(self, client): """Gets projects from all teams in the account.""" projects_in_account = [] teams = self.getTeamsFromAccount(client) for team in teams: projects_in_team = (self.getProjectsFromTeam(client, team)) projects_in_account.extend(projects_in_team) return projects_in_account def test(self): """Testing method""" me = self.fio.get_me() print(me['id']) print(self.sg._connection) print(self.__fio_token) print(self.sg_url) print(self.sg_user) print(self.__sg_pass) print("Location: " + self.location)
def add_metadata(asset_id,metadata): token = getenv("FRAME_IO_TOKEN") client = FrameioClient(token) client.update_asset(asset_id, description=metadata)
def main(): client = FrameioClient("TOKEN") me = client.get_me() print(me['id'])
def setup_client(): client = FrameioClient(token) return client