Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.0
current_version = 1.2.0
commit = True
tag = True

Expand Down
15 changes: 13 additions & 2 deletions frameioclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

from .lib import ClientVersion, PaginatedResponse, Utils, ClientVersion, FrameioDownloader

from .lib import (
ClientVersion,
PaginatedResponse,
Utils,
ClientVersion,
FrameioDownloader,
PresentationException
)

class FrameioConnection(object):
def __init__(self, token, host='https://api.frame.io'):
Expand Down Expand Up @@ -128,3 +134,8 @@ def projects(self):
def teams(self):
from .service import Team
return Team(self)

@property
def helpers(self):
from .service import FrameioHelpers
return FrameioHelpers(self)
2 changes: 1 addition & 1 deletion frameioclient/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .upload import FrameioUploader
from .utils import Utils, PaginatedResponse, KB, MB
from .exceptions import *
from .version import ClientVersion
from .version import ClientVersion
12 changes: 9 additions & 3 deletions frameioclient/lib/download.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io
import os
import sys
import math
import time
import requests
Expand All @@ -12,7 +13,7 @@
thread_local = threading.local()

class FrameioDownloader(object):
def __init__(self, asset, download_folder, prefix, multi_part=False, concurrency=5):
def __init__(self, asset, download_folder, prefix, multi_part=False, concurrency=5, replace=False):
self.multi_part = multi_part
self.asset = asset
self.asset_type = None
Expand All @@ -27,6 +28,7 @@ def __init__(self, asset, download_folder, prefix, multi_part=False, concurrency
self.chunks = math.ceil(self.file_size/self.chunk_size)
self.prefix = prefix
self.filename = Utils.normalize_filename(asset["name"])
self.replace = replace

self._evaluate_asset()

Expand All @@ -48,8 +50,12 @@ def _create_file_stub(self):
# fp.write(b"\0" * self.file_size) # Disabled to prevent pre-allocatation of disk space
fp.close()
except FileExistsError as e:
print(e)
raise e
if self.replace == True:
os.remove(self.destination) # Remove the file
self._create_file_stub() # Create a new stub
else:
print(e)
raise e
return True

def get_download_key(self):
Expand Down
3 changes: 2 additions & 1 deletion frameioclient/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
from .logs import AuditLogs
from .comments import Comment
from .projects import Project
from .links import ReviewLink, PresentationLink
from .links import ReviewLink, PresentationLink
from .helpers import FrameioHelpers
20 changes: 19 additions & 1 deletion frameioclient/service/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ def create(self, parent_asset_id, **kwargs):
endpoint = '/assets/{}/children'.format(parent_asset_id)
return self.client._api_call('post', endpoint, payload=kwargs)

def create_folder(self, parent_asset_id, name="New Folder"):
"""
Create a new folder.

:Args:
parent_asset_id (string): The parent asset id.
name (string): The name of the new folder.

Example::

client.assets.create_folder(
parent_asset_id="123abc",
name="ExampleFile.mp4",
)
"""
endpoint = '/assets/{}/children'.format(parent_asset_id)
return self.client._api_call('post', endpoint, payload={"name": name, "type":"folder"})

def from_url(self, parent_asset_id, name, url):
"""
Create an asset from a URL.
Expand Down Expand Up @@ -242,7 +260,7 @@ def upload(self, destination_id, filepath, asset=None):

return asset

def download(self, asset, download_folder, prefix=None, multi_part=False, concurrency=5):
def download(self, asset, download_folder, prefix=None, multi_part=False, concurrency=5, replace=False):
"""
Download an asset. The method will exit once the file is downloaded.

Expand Down
32 changes: 32 additions & 0 deletions frameioclient/service/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from .service import Service

class FrameioHelpers(Service):
def get_updated_assets(self, account_id, project_id, timestamp):
"""
Get assets added or updated since timestamp.

:Args:
account_id (string): The account id.
project_id (string): The project id.
timestamp (string): ISO 8601 UTC format.
(datetime.now(timezone.utc).isoformat())
"""
payload = {
"account_id": account_id,
"page": 1,
"page_size": 50,
"include": "children",
"sort": "-inserted_at",
"filter": {
"project_id": {
"op": "eq",
"value": project_id
},
"updated_at": {
"op": "gte",
"value": timestamp
}
}
}
endpoint = '/search/library'
return self.client._api_call('post', endpoint, payload=payload)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools.command.install import install

version='1.1.0'
version='1.2.0'

with open("README.md", "r") as f:
long_description = f.read()
Expand Down