Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Issue #539, the url may not be a valid url #545

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kubespider/api/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Resource(Extra):
Resource, used to describe the resource to be downloaded, result of the source provider
"""

def __init__(self, url: str, path: str,
def __init__(self, *, url: str, path: str,
link_type: str = None, file_type: str = None, uid: str = None,
**kwargs):
super().__init__(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ def is_webhook_enable(self) -> bool:

def should_handle(self, event: Event) -> bool:
parse_url = urlparse(event.source)
# Issue #539, the url may not be a valid url
if not parse_url:
return False
if parse_url.hostname.endswith('btbtt12.com') and 'attach-dialog-fid' in parse_url.path:
if parse_url.hostname and parse_url.hostname.endswith('btbtt12.com') and 'attach-dialog-fid' in parse_url.path:
logging.info('%s belongs to Btbtt12DisposableSourceProvider', event.source)
return True
return False
Expand Down
6 changes: 5 additions & 1 deletion kubespider/source_provider/magic_source_provider/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def is_webhook_enable(self) -> bool:

def should_handle(self, event: Event) -> bool:
data_source_url = event.source
if urlparse(data_source_url).hostname in self.handle_host:
# Issue #539, the url may not be a valid url
parse_url = urlparse(data_source_url)
if not parse_url:
return False
if parse_url.hostname in self.handle_host:
logging.info('%s belongs to %s', data_source_url, self.provider_name)
return True
return False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def is_webhook_enable(self) -> bool:

def should_handle(self, event: Event) -> bool:
parse_url = urlparse(event.source)
# Issue #539, the url may not be a valid url
if not parse_url:
return False
if parse_url.hostname in ('www.youtube.com', 'youtube.com', 'm.youtube.com', 'youtu.be'):
logging.info('%s belongs to youtube_source_provider', event.source)
return True
Expand Down
Loading