Skip to content

Commit

Permalink
Merge pull request #59 from Mirio/develop
Browse files Browse the repository at this point in the history
Adding urlparser for sanification the input
  • Loading branch information
Mirio authored Oct 8, 2023
2 parents 793e724 + c5966c6 commit d58e521
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ With VerbaCap is a **Podcast Manager** you will be able to download and listen t
It uses [_Django_](https://www.djangoproject.com/) in order to create a new integration for the platform as easy as possible. Below a quick platform integrated and the current status.

:heavy_check_mark: Youtube Channel :heavy_check_mark: Youtube Playlist
:construction: Spreaker.com
:heavy_check_mark: Spreaker.com
:construction: Apple Podcast :construction: Amazon Music

[Installation](docs/install.md)[Configuration](docs/config.md)
Expand Down
10 changes: 7 additions & 3 deletions spreaker/services.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os.path import exists
from urllib.parse import urlparse

import feedparser
import requests
Expand All @@ -10,7 +11,8 @@

def get_rssurl(input_url: str) -> CommonResponse:
out = CommonResponse()
if not input_url.startswith("https://www.spreaker.com/show/"):
inputurl_parsed = urlparse(input_url)
if not inputurl_parsed.path.startswith("/show") or inputurl_parsed.hostname != "www.spreaker.com":
out.status = "error"
out.message = "Not a spreaker url"
else:
Expand All @@ -29,7 +31,8 @@ def get_rssurl(input_url: str) -> CommonResponse:
def get_rss_data(input_url: str, limit: int = 10) -> CommonResponse:
out = CommonResponse()
counter = 0
if not input_url.startswith("https://www.spreaker.com/show/"):
inputurl_parsed = urlparse(input_url)
if not inputurl_parsed.path.startswith("/show") or inputurl_parsed.hostname != "www.spreaker.com":
out.status = "error"
out.message = "Not a spreaker url"
else:
Expand All @@ -45,7 +48,8 @@ def get_rss_data(input_url: str, limit: int = 10) -> CommonResponse:

def get_audio(input_url: str, fname: str) -> CommonResponse:
out = CommonResponse()
if not input_url.startswith("https://dts.podtrac.com") and not input_url.startswith("https://api.spreaker.com"):
inputurl_parsed = urlparse(input_url)
if inputurl_parsed.hostname != "api.spreaker.com" and inputurl_parsed.hostname != "dts.podtrac.com":
out.status = "error"
out.message = "Not a spreaker url"
else:
Expand Down
14 changes: 9 additions & 5 deletions youtube/services.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from os.path import exists
from urllib.parse import parse_qs
from urllib.parse import parse_qs, urlparse

import feedparser
import requests
Expand All @@ -13,7 +13,8 @@

def get_channel_rssurl(input_url: str) -> CommonResponse:
out = CommonResponse()
if not input_url.startswith("https://www.youtube.com/"):
inputurl_parsed = urlparse(input_url)
if inputurl_parsed.hostname != "www.youtube.com":
out.status = "error"
out.message = "Not a youtube url"
else:
Expand All @@ -32,7 +33,8 @@ def get_channel_rssurl(input_url: str) -> CommonResponse:

def get_playlist_rssurl(input_url: str) -> CommonResponse:
out = CommonResponse()
if not input_url.startswith("https://www.youtube.com/"):
inputurl_parsed = urlparse(input_url)
if inputurl_parsed.hostname != "www.youtube.com":
out.status = "error"
out.message = "Not a youtube url"
elif "&list=" not in input_url:
Expand All @@ -47,9 +49,10 @@ def get_playlist_rssurl(input_url: str) -> CommonResponse:

def get_rss_data(input_url: str, limit: int = 10) -> CommonResponse:
out = CommonResponse()
inputurl_parsed = urlparse(input_url)
counter = 0
if input_url:
if not input_url.startswith("https://www.youtube.com/"):
if inputurl_parsed.hostname != "www.youtube.com":
out.status = "error"
out.message = "Not a youtube url"
else:
Expand All @@ -68,7 +71,8 @@ def get_rss_data(input_url: str, limit: int = 10) -> CommonResponse:

def get_audio(input_url: str, fname: str) -> CommonResponse:
out = CommonResponse()
if not input_url.startswith("https://www.youtube.com/"):
inputurl_parsed = urlparse(input_url)
if inputurl_parsed.hostname != "www.youtube.com":
out.status = "error"
out.message = "Not a youtube url"
else:
Expand Down

0 comments on commit d58e521

Please sign in to comment.