Skip to content

Commit 09a5b6f

Browse files
remove cloud dependencies
1 parent 043f45c commit 09a5b6f

10 files changed

Lines changed: 4 additions & 242 deletions

File tree

.appveyor.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@ install:
3434
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
3535
- python -m pip install -U pip
3636
- python -m easy_install -U setuptools
37-
# - pip install -e .[test]
38-
# - pip install --upgrade virtualenv
3937
- pip install -r requirements.txt
40-
# - pip install requests
41-
# - pip install boto3
42-
# - pip install azure-storage-blob
43-
# - pip install google-cloud-storage
4438
- ps: Start-FileDownload $env:ffmpeg_download
4539

4640
- 7z x ffmpeg-20190225-f948082-win64-static.zip

.github/workflows/pythonpackage.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ jobs:
2121
run: |
2222
python -m pip install --upgrade pip
2323
pip install -r requirements.txt
24-
# pip install requests
25-
# pip install boto3
26-
# pip install google-cloud-storage
27-
# pip install azure-storage-blob
2824
- name: Install ffmpeg
2925
run: |
3026
sudo apt-get update

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ language: python
33
before_install:
44
- python -m pip install --upgrade pip
55
- pip install -r requirements.txt
6-
# - pip install requests
7-
# - pip install boto3
8-
# - pip install google-cloud-storage
9-
# - pip install azure-storage-blob
106
- >
117
[ -f ffmpeg-release/ffmpeg ] || (
128
curl -O https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz &&

Pipfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ url = "https://pypi.org/project/python-ffmpeg-video-streaming/"
44
verify_ssl = true
55

66
[packages]
7-
requests = "2.22.0"
8-
boto3 = "1.9.243"
9-
google-cloud-storage = "1.20.0"
10-
azure-storage-blob = "2.1.0"
117

128
[requires]
13-
python_version = "3.7"
9+
python_version = "3.6"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
This package uses the **[FFmpeg](https://ffmpeg.org)** to package media content for online streaming such as DASH and HLS. You can also use **[DRM](https://en.wikipedia.org/wiki/Digital_rights_management)** for HLS packaging. There are several options to open a file from clouds and save files to them as well.
1010

1111
- The best way to learn how to use this library is to review ****[the examples](https://github.com/aminyazdanpanah/python-ffmpeg-video-streaming/tree/master/examples)**** and browse the source code.
12-
- Cloud dependencies are deprecated now and will be removed in a future release. For using clouds such as **[Amazon S3](https://aws.amazon.com/s3)**, **[Google Cloud Storage](https://console.cloud.google.com/storage)**, **[Microsoft Azure Storage](https://azure.microsoft.com/en-us/features/storage-explorer/)**, and a custom cloud, please visit **[this page](https://video.aminyazdanpanah.com/python/start/clouds)**
12+
- For using clouds such as **[Amazon S3](https://aws.amazon.com/s3)**, **[Google Cloud Storage](https://console.cloud.google.com/storage)**, **[Microsoft Azure Storage](https://azure.microsoft.com/en-us/features/storage-explorer/)**, and a custom cloud, please visit **[this page](https://video.aminyazdanpanah.com/python/start/clouds)**.
1313

1414
**Contents**
1515
- [Requirements](#requirements)

examples/clouds/google_cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def google_cloud(bucket_name, object_name):
6060
'object_name': object_name,
6161
}
6262
upload_options = {
63-
'encryption': 'SOME_BASE64_ENCRYPTION',
63+
'encryption': 'BASE64_ENCRYPTION',
6464
}
6565

6666
from_google_cloud = (cloud, download_options, None)

ffmpeg_streaming/clouds.py

Lines changed: 0 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@
1212
"""
1313

1414
import abc
15-
import sys
16-
import tempfile
17-
18-
from os import listdir
19-
from os.path import isfile, join
20-
21-
import boto3
22-
import botocore
23-
import requests
24-
from azure.storage.blob import BlockBlobService
25-
from google.cloud import storage
26-
27-
from ffmpeg_streaming.utiles import deprecated
2815

2916

3017
class Clouds(abc.ABC):
@@ -37,156 +24,6 @@ def download(self, filename=None, **options):
3724
pass
3825

3926

40-
class Cloud(Clouds):
41-
@deprecated
42-
def upload_directory(self, directory, **options):
43-
field_name = options.pop('field_name', None)
44-
45-
if field_name is None:
46-
raise ValueError('You should specify a field_name')
47-
48-
method = options.pop('method', 'post')
49-
url = options.pop('url', None)
50-
upload_files = []
51-
52-
files = [f for f in listdir(directory) if isfile(join(directory, f))]
53-
54-
for file in files:
55-
full_path_file = directory + file
56-
upload_files.append((field_name, open(full_path_file, 'rb')))
57-
58-
r = requests.request(method, url, files=upload_files, **options)
59-
60-
if not r.ok:
61-
raise RuntimeError('Error uploading file!')
62-
63-
@deprecated
64-
def download(self, filename=None, **options):
65-
progress = options.pop('progress', None)
66-
method = options.pop('method', 'get')
67-
url = options.pop('url', None)
68-
69-
if url is None:
70-
raise ValueError('You should specify an url')
71-
72-
if filename is None:
73-
file = tempfile.NamedTemporaryFile(suffix='_py_ff_vi_st.tmp', delete=False)
74-
else:
75-
file = open(filename, 'wb')
76-
77-
with file as f:
78-
response = requests.request(method, url, stream=True, **options)
79-
total_byte = response.headers.get('content-length')
80-
81-
if total_byte is None or not callable(progress):
82-
f.write(response.content)
83-
else:
84-
downloaded = 0
85-
total_byte = int(total_byte)
86-
for data in response.iter_content(chunk_size=4096):
87-
downloaded += len(data)
88-
f.write(data)
89-
percentage = round(100 * downloaded / total_byte)
90-
progress(percentage, downloaded, total_byte)
91-
sys.stdout.write('\n')
92-
93-
return f.name
94-
95-
96-
class AWS(Clouds):
97-
def __init__(self, **options):
98-
self.s3 = boto3.client('s3', options)
99-
100-
@deprecated
101-
def upload_directory(self, directory, **options):
102-
bucket_name = options.pop('bucket_name', None)
103-
if bucket_name is None:
104-
raise ValueError('You should pass a bucket name')
105-
106-
files = [f for f in listdir(directory) if isfile(join(directory, f))]
107-
for file in files:
108-
full_path_file = directory + file
109-
self.s3.upload_file(full_path_file, bucket_name, file)
110-
111-
@deprecated
112-
def download(self, filename=None, **options):
113-
if filename is None:
114-
tmp = tempfile.NamedTemporaryFile(suffix='_py_ff_vi_st.tmp', delete=False)
115-
filename = tmp.name
116-
117-
bucket_name = options.pop('bucket_name', None)
118-
key = options.pop('key', None)
119-
if bucket_name is None or key is None:
120-
raise ValueError('You should pass a bucket name and a key')
121-
122-
try:
123-
self.s3.Bucket(bucket_name).download_file(key, filename)
124-
except botocore.exceptions.ClientError as e:
125-
if e.response['Error']['Code'] == "404":
126-
raise RuntimeError("The object does not exist.")
127-
else:
128-
raise RuntimeError("Could not connect to the server")
129-
130-
return filename
131-
132-
133-
class GoogleCloudStorage(Clouds):
134-
def __init__(self, bucket_name, **kwargs):
135-
storage_client = storage.Client(**kwargs)
136-
self.bucket_name = bucket_name
137-
self.bucket = storage_client.get_bucket(bucket_name)
138-
139-
@deprecated
140-
def upload_directory(self, directory, **options):
141-
files = [f for f in listdir(directory) if isfile(join(directory, f))]
142-
143-
for file in files:
144-
full_path_file = directory + file
145-
blob = self.bucket.blob(self.bucket_name + file, options)
146-
blob.upload_from_filename(full_path_file)
147-
148-
@deprecated
149-
def download(self, filename=None, **options):
150-
if filename is None:
151-
tmp = tempfile.NamedTemporaryFile(suffix='_py_ff_vi_st.tmp', delete=False)
152-
filename = tmp.name
153-
154-
object_name = options.pop('object_name', None)
155-
if object_name is None:
156-
raise ValueError('You should pass an object name')
157-
158-
blob = self.bucket.get_blob(object_name, options)
159-
blob.download_to_filename(filename)
160-
161-
return filename
162-
163-
164-
class MicrosoftAzure(Clouds):
165-
def __init__(self, **options):
166-
self.block_blob_service = BlockBlobService(**options)
167-
168-
@deprecated
169-
def upload_directory(self, directory, **options):
170-
files = [f for f in listdir(directory) if isfile(join(directory, f))]
171-
container = options.pop('container', None)
172-
for file in files:
173-
full_path_file = directory + file
174-
self.block_blob_service.create_blob_from_path(container, file, full_path_file)
175-
176-
@deprecated
177-
def download(self, filename=None, **options):
178-
if filename is None:
179-
tmp = tempfile.NamedTemporaryFile(suffix='_py_ff_vi_st.tmp', delete=False)
180-
filename = tmp.name
181-
182-
container = options.pop('container', None)
183-
blob = options.pop('blob', None)
184-
185-
self.block_blob_service.get_blob_to_path(container, blob, filename)
186-
187-
return filename
188-
189-
19027
def open_from_cloud(cloud):
19128
cloud = dict(enumerate(cloud))
19229

@@ -227,8 +64,4 @@ def save_to_clouds(clouds, dirname):
22764

22865
__all__ = [
22966
'Clouds',
230-
'Cloud',
231-
'AWS',
232-
'GoogleCloudStorage',
233-
'MicrosoftAzure'
23467
]

ffmpeg_streaming/from_clouds.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

ffmpeg_streaming/progress.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
def progress(line, total_sec):
2020
time = re.search('(?<=time=)\w+:\w+:\w+', line)
2121
if time:
22-
sec = convert_to_sec(time.group(0))
23-
return round(100 * sec / total_sec)
22+
return round(100 * convert_to_sec(time.group(0)) / total_sec)
2423

2524

2625
def get_duration_sec(line):

requirements.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
requests==2.22.0
2-
boto3==1.9.243
3-
google-cloud-storage==1.20.0
4-
azure-storage-blob==2.1.0

0 commit comments

Comments
 (0)