mixpeek 0.7.1__py3-none-any.whl → 0.7.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mixpeek/endpoints/index.py +24 -31
- mixpeek/endpoints/search.py +24 -17
- mixpeek/endpoints/tools.py +32 -0
- {mixpeek-0.7.1.dist-info → mixpeek-0.7.3.dist-info}/METADATA +2 -1
- {mixpeek-0.7.1.dist-info → mixpeek-0.7.3.dist-info}/RECORD +7 -7
- {mixpeek-0.7.1.dist-info → mixpeek-0.7.3.dist-info}/WHEEL +0 -0
- {mixpeek-0.7.1.dist-info → mixpeek-0.7.3.dist-info}/top_level.txt +0 -0
mixpeek/endpoints/index.py
CHANGED
@@ -5,31 +5,29 @@ class Index:
|
|
5
5
|
self.base_url = base_url
|
6
6
|
self.headers = headers
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
8
|
+
def _prepare_data(self, base_data, metadata=None, settings=None):
|
9
|
+
if metadata is not None:
|
10
|
+
base_data["metadata"] = metadata
|
11
|
+
if settings is not None:
|
12
|
+
base_data["settings"] = settings
|
13
|
+
return base_data
|
14
|
+
|
15
|
+
# def upload(self, file, collection_id, metadata=None, settings=None):
|
16
|
+
# try:
|
17
|
+
# api_url = f"{self.base_url}index/upload"
|
18
|
+
# files = {"file": file}
|
19
|
+
# data = self._prepare_data({"collection_id": collection_id}, metadata, settings)
|
20
|
+
# response = requests.post(api_url, files=files, data=data, headers=self.headers)
|
21
|
+
# response.raise_for_status()
|
22
|
+
# return response.json()
|
23
|
+
# except requests.RequestException as e:
|
24
|
+
# return {"error": str(e)}
|
22
25
|
|
23
|
-
def url(self,
|
26
|
+
def url(self, target_url, collection_id, metadata=None, settings=None):
|
24
27
|
try:
|
25
|
-
|
26
|
-
data = {
|
27
|
-
|
28
|
-
"collection_id": collection_id,
|
29
|
-
"metadata": metadata,
|
30
|
-
"settings": settings
|
31
|
-
}
|
32
|
-
response = requests.post(url, json=data, headers=self.headers)
|
28
|
+
endpoint = f"{self.base_url}index/url"
|
29
|
+
data = self._prepare_data({"url": target_url, "collection_id": collection_id}, metadata, settings)
|
30
|
+
response = requests.post(endpoint, json=data, headers=self.headers)
|
33
31
|
response.raise_for_status()
|
34
32
|
return response.json()
|
35
33
|
except requests.RequestException as e:
|
@@ -37,14 +35,9 @@ class Index:
|
|
37
35
|
|
38
36
|
def youtube(self, youtube_video_id, collection_id, metadata=None, settings=None):
|
39
37
|
try:
|
40
|
-
|
41
|
-
data = {
|
42
|
-
|
43
|
-
"collection_id": collection_id,
|
44
|
-
"metadata": metadata,
|
45
|
-
"settings": settings
|
46
|
-
}
|
47
|
-
response = requests.post(url, json=data, headers=self.headers)
|
38
|
+
api_url = f"{self.base_url}index/youtube"
|
39
|
+
data = self._prepare_data({"youtube_video_id": youtube_video_id, "collection_id": collection_id}, metadata, settings)
|
40
|
+
response = requests.post(api_url, json=data, headers=self.headers)
|
48
41
|
response.raise_for_status()
|
49
42
|
return response.json()
|
50
43
|
except requests.RequestException as e:
|
mixpeek/endpoints/search.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
import requests
|
2
|
+
import os
|
3
|
+
import json
|
2
4
|
|
3
5
|
class Search:
|
4
6
|
def __init__(self, base_url, headers):
|
@@ -25,27 +27,32 @@ class Search:
|
|
25
27
|
except requests.RequestException as e:
|
26
28
|
return {"error": str(e)}
|
27
29
|
|
28
|
-
def upload(self,
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
# def upload(self, file_path, filters=None, page=1, page_size=10):
|
31
|
+
# try:
|
32
|
+
# url = f"{self.base_url}search/upload"
|
33
|
+
|
34
|
+
# filename = os.path.basename(file_path)
|
35
|
+
# files = {
|
36
|
+
# 'file': (filename, open(file_path, 'rb'), 'application/octet-stream')
|
37
|
+
# }
|
38
|
+
|
39
|
+
# payload = {
|
40
|
+
# 'filters': json.dumps(filters or {}),
|
41
|
+
# 'page': str(page),
|
42
|
+
# 'page_size': str(page_size)
|
43
|
+
# }
|
44
|
+
|
45
|
+
# response = requests.post(url, headers=self.headers, data=payload, files=files)
|
46
|
+
# response.raise_for_status()
|
47
|
+
# return response.json()
|
48
|
+
# except requests.RequestException as e:
|
49
|
+
# return {"error": str(e)}
|
42
50
|
|
43
|
-
def url(self,
|
51
|
+
def url(self, target_url, filters=None, modality="text", page=1, page_size=10):
|
44
52
|
try:
|
45
53
|
url = f"{self.base_url}search/url"
|
46
54
|
data = {
|
47
|
-
"url":
|
48
|
-
"input_type": input_type,
|
55
|
+
"url": target_url,
|
49
56
|
"filters": filters or {},
|
50
57
|
"modality": modality,
|
51
58
|
"pagination": {
|
mixpeek/endpoints/tools.py
CHANGED
@@ -5,10 +5,41 @@ import base64
|
|
5
5
|
from urllib.parse import urlparse
|
6
6
|
from urllib.request import urlretrieve
|
7
7
|
from tqdm import tqdm
|
8
|
+
from PIL import Image
|
9
|
+
import io
|
8
10
|
|
9
11
|
class Tools:
|
10
12
|
def __init__(self):
|
11
13
|
self.video = self.Video(self)
|
14
|
+
self.image = self.Image(self)
|
15
|
+
|
16
|
+
class Image:
|
17
|
+
def __init__(self, parent):
|
18
|
+
pass
|
19
|
+
|
20
|
+
def process(self, image_source: str):
|
21
|
+
# Download image if it's a URL
|
22
|
+
if urlparse(image_source).scheme in ('http', 'https'):
|
23
|
+
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
24
|
+
urlretrieve(image_source, temp_file.name)
|
25
|
+
image_source = temp_file.name
|
26
|
+
|
27
|
+
# Open and process the image
|
28
|
+
with Image.open(image_source) as img:
|
29
|
+
# Convert image to RGB mode if it's not already
|
30
|
+
if img.mode != 'RGB':
|
31
|
+
img = img.convert('RGB')
|
32
|
+
|
33
|
+
# Convert image to base64
|
34
|
+
buffered = io.BytesIO()
|
35
|
+
img.save(buffered, format="JPEG")
|
36
|
+
base64_string = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
37
|
+
|
38
|
+
# Remove temporary file if it was created
|
39
|
+
if urlparse(image_source).scheme in ('http', 'https'):
|
40
|
+
os.unlink(image_source)
|
41
|
+
|
42
|
+
return base64_string
|
12
43
|
|
13
44
|
class Video:
|
14
45
|
def __init__(self, parent):
|
@@ -25,6 +56,7 @@ class Tools:
|
|
25
56
|
}
|
26
57
|
yield data
|
27
58
|
|
59
|
+
|
28
60
|
class VideoChunker:
|
29
61
|
def __init__(self, video_source, chunk_interval, target_resolution):
|
30
62
|
self.video_source = video_source
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: mixpeek
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.3
|
4
4
|
Summary: Mixpeek Python SDK
|
5
5
|
Home-page: https://github.com/mixpeek/mixpeek-python
|
6
6
|
Author: Ethan Steininger
|
@@ -14,6 +14,7 @@ Requires-Dist: requests ==2.32.3
|
|
14
14
|
Requires-Dist: pydantic ==2.7.3
|
15
15
|
Requires-Dist: tqdm ==4.66.4
|
16
16
|
Requires-Dist: urllib3 ==2.2.1
|
17
|
+
Requires-Dist: pillow ==10.4.0
|
17
18
|
|
18
19
|
# Mixpeek Python SDK
|
19
20
|
|
@@ -4,10 +4,10 @@ mixpeek/exceptions.py,sha256=Orhdo5UFLn3fcWVJtlgkznW8Iy5ndL96h0qTY8zOlDA,235
|
|
4
4
|
mixpeek/endpoints/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
mixpeek/endpoints/collections.py,sha256=ffOBenNHG-mVpjT7kQcOfn78-wjgjdQTVyrloyeAy90,2890
|
6
6
|
mixpeek/endpoints/embed.py,sha256=ybDqyIt0oJiwIdH1QSwuV-CPeJgd-zW0etNAcBdgZYE,2290
|
7
|
-
mixpeek/endpoints/index.py,sha256=
|
8
|
-
mixpeek/endpoints/search.py,sha256=
|
9
|
-
mixpeek/endpoints/tools.py,sha256=
|
10
|
-
mixpeek-0.7.
|
11
|
-
mixpeek-0.7.
|
12
|
-
mixpeek-0.7.
|
13
|
-
mixpeek-0.7.
|
7
|
+
mixpeek/endpoints/index.py,sha256=QgMgys1CCukepCpK351aVXRxEsxBfI2YriX7aaH1NrU,1939
|
8
|
+
mixpeek/endpoints/search.py,sha256=u3onbss7Llx0AgcTSRtel6bGO5Ly3jvraXPcA26GzsY,2387
|
9
|
+
mixpeek/endpoints/tools.py,sha256=T8qb9zngY3V_vwtmBBrTqPvqZl1QIL8q3at3UGIj4bg,4709
|
10
|
+
mixpeek-0.7.3.dist-info/METADATA,sha256=AO5vsb1itiebws3tEFrXnHuywAZei3TBgRXVW3Lfgy4,10616
|
11
|
+
mixpeek-0.7.3.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
12
|
+
mixpeek-0.7.3.dist-info/top_level.txt,sha256=EJ8Jc4IhqyUwnUlBwKbs498Ju4O9a-IDh2kXc_lo6Vg,8
|
13
|
+
mixpeek-0.7.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|