Skip to content

Commit 3f7d379

Browse files
committed
Improve doc strings and add arbitrary range request
1 parent ac44fc4 commit 3f7d379

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

frameioclient/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from requests.adapters import HTTPAdapter
55
from requests.packages.urllib3.util.retry import Retry
66

7-
from .lib import ClientVersion, PaginatedResponse, Utils, ClientVersion
7+
from .lib import ClientVersion, PaginatedResponse, Utils, ClientVersion, FrameioDownloader
88

99

1010
class FrameioConnection(object):
@@ -85,6 +85,10 @@ def _auth(self):
8585
def _version(self):
8686
return ClientVersion.version()
8787

88+
@property
89+
def _download(self):
90+
return FrameioDownloader
91+
8892
@property
8993
def users(self):
9094
from .service import User

frameioclient/lib/download.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def multi_part_download(self, url):
138138
out_byte = offset * (i+1) # Increment by the iterable + 1 so we don't mutiply by zero
139139
task = (url, in_byte, out_byte, i)
140140

141+
time.sleep(0.1) # Stagger start for each chunk by 0.1 seconds
141142
self.futures.append(executor.submit(self.download_chunk, task))
142143
in_byte = out_byte # Reset new in byte equal to last out byte
143144

@@ -180,3 +181,9 @@ def download_chunk(self, task):
180181
print("Done writing chunk {}/{}".format(chunk_number + 1, self.chunks))
181182

182183
return "Complete!"
184+
185+
@staticmethod
186+
def get_byte_range(url, start_byte=0, end_byte=2048):
187+
headers = {"Range": "bytes=%d-%d" % (start_byte, end_byte)}
188+
br = requests.get(url, headers=headers).content
189+
return br

frameioclient/service/assets.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def create(self, parent_asset_id, **kwargs):
3838
3939
Example::
4040
41-
client.create_asset(
41+
client.assets.create(
4242
parent_asset_id="123abc",
4343
name="ExampleFile.mp4",
4444
type="file",
@@ -119,7 +119,7 @@ def bulk_copy(self, destination_folder_id, asset_list=[], copy_comments=False):
119119
copy_comments (boolean): Whether or not to copy comments: True or False.
120120
121121
Example::
122-
client.assets.buly_copy("adeffee123342", asset_list=["7ee008c5-49a2-f8b5-997d-8b64de153c30", \
122+
client.assets.bulk_copy("adeffee123342", asset_list=["7ee008c5-49a2-f8b5-997d-8b64de153c30", \
123123
"7ee008c5-49a2-f8b5-997d-8b64de153c30"], copy_comments=True)
124124
"""
125125

@@ -154,8 +154,7 @@ def _upload(self, asset, file):
154154
file (file): The file to upload.
155155
156156
Example::
157-
158-
client.upload(asset, open('example.mp4')) // TODO fix this example (bad way of opening file)
157+
client.upload(asset, open('example.mp4'))
159158
"""
160159

161160
uploader = FrameioUploader(asset, file)

0 commit comments

Comments
 (0)