Skip to content

Commit 817e1ae

Browse files
author
Steven Jiang
authored
Merge pull request #73 from ourzora/steve-fix-mime-type-for-manifold
fix: mime type fetching for manifold
2 parents 4b006fb + 019ee2d commit 817e1ae

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.1.4
4+
5+
- bug fix: parse mime type for Manifold NFT metadata
6+
37
## v0.1.3
48

59
- bug fix: add a type check to `should_parse_token()` in `OpenseaParser` to validate that `raw_data` is a `dict`

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting Started
22

3-
Documentation for version: **v0.1.3**
3+
Documentation for version: **v0.1.4**
44

55
## Overview
66

offchain/constants/providers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33

44
class RPCProvider(StringEnum):
55
CLOUDFLARE_MAINNET = "https://cloudflare-eth.com"
6+
LLAMA_NODES_MAINNET = "https://eth.llamarpc.com"

offchain/metadata/fetchers/metadata_fetcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,6 @@ def fetch_content(self, uri: str) -> Union[dict, str]:
100100
return res.json()
101101
else:
102102
return res.text
103+
103104
except Exception as e:
104105
raise Exception(f"Don't know how to fetch metadata for {uri=}. {str(e)}")

offchain/metadata/parsers/catchall/default_catchall.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ def get_image_details(self, raw_data: dict) -> Optional[MediaDetails]:
7878
if not image_uri:
7979
return None
8080
details = MediaDetails(uri=image_uri, size=None, sha256=None, mime_type=None)
81-
if isinstance(raw_data.get("image_details"), dict):
82-
details.size = raw_data["image_details"].get("size")
83-
details.sha256 = raw_data["image_details"].get("sha256")
84-
return details
8581
try:
8682
content_type, size = self.fetcher.fetch_mime_type_and_size(image_uri)
87-
details.mime_type = content_type
8883
details.size = size
84+
details.mime_type = content_type
8985
except Exception:
9086
pass
87+
88+
if isinstance(raw_data.get("image_details"), dict):
89+
details.size = raw_data["image_details"].get("size")
90+
details.sha256 = raw_data["image_details"].get("sha256")
9191
return details
9292

9393
def get_content_uri(self, raw_data: dict):
@@ -102,17 +102,15 @@ def get_content_details(self, raw_data: dict) -> Optional[MediaDetails]:
102102
if not content_uri:
103103
return None
104104
details = MediaDetails(uri=content_uri, size=None, sha256=None, mime_type=None)
105-
if isinstance(raw_data.get("animation_details"), dict):
106-
details.size = raw_data["animation_details"].get("size")
107-
details.sha256 = raw_data["animation_details"].get("sha256")
108-
return details
109105
try:
110106
content_type, size = self.fetcher.fetch_mime_type_and_size(content_uri)
111-
details.mime_type = content_type
112107
details.size = size
108+
details.mime_type = content_type
113109
except Exception:
114110
pass
115-
111+
if isinstance(raw_data.get("animation_details"), dict):
112+
details.size = raw_data["animation_details"].get("size")
113+
details.sha256 = raw_data["animation_details"].get("sha256")
116114
return details
117115

118116
def parse_metadata(self, token: Token, raw_data: dict, *args, **kwargs) -> Optional[Metadata]:

offchain/web3/jsonrpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(
2929
self.sess.mount("https://", adapter)
3030
self.sess.mount("http://", adapter)
3131
self.sess.headers = {"Content-Type": "application/json"}
32-
self.url = provider_url or RPCProvider.CLOUDFLARE_MAINNET
32+
self.url = provider_url or RPCProvider.LLAMA_NODES_MAINNET
3333

3434
def __payload_factory(self, method: str, params: list[Any], id: int) -> RPCPayload:
3535
return {"method": method, "params": params, "id": id, "jsonrpc": "2.0"}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "offchain"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
description = "Open source metadata processing framework"
55
authors = ["Zora eng <[email protected]>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)