Skip to content

Commit

Permalink
fix: Use initialized registry
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei committed Apr 28, 2024
1 parent 6254cac commit 5a101aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion oembedpy/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def fetch(
) -> Content:
"""Find endpoint from registry and content."""
try:
api_url, params = discovery.find_from_registry(url)
api_url, params = discovery.find_from_registry(url, self._registry)
except ValueError: # TODO: Split error case?
logger.warning("It is not found from registry. Try from content.")
api_url, params = discovery.find_from_content(url)
Expand Down
8 changes: 2 additions & 6 deletions oembedpy/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import logging
import urllib.parse
from typing import Optional, Tuple
from typing import Tuple

import httpx
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -50,13 +50,9 @@ def find_from_content(url: str) -> Tuple[str, RequestParameters]:


def find_from_registry(
url: str, registry: Optional[ProviderRegistry] = None
url: str, registry: ProviderRegistry
) -> Tuple[str, RequestParameters]:
"""Find endpoint matched for content from registry."""
if registry is None:
resp = httpx.get("https://oembed.com/providers.json")
registry = ProviderRegistry.from_dict(resp.json())

for provider in registry.providers:
api_url = provider.find_endpoint(url)
if api_url:
Expand Down

0 comments on commit 5a101aa

Please sign in to comment.