s
This commit is contained in:
parent
322010cb8a
commit
804bf34a16
@ -1,4 +1,9 @@
|
|||||||
|
from urllib.parse import urlparse
|
||||||
|
import re
|
||||||
|
|
||||||
from .base_classes import Section, FloatAttribute, IntAttribute, BoolAttribute, ListAttribute
|
from .base_classes import Section, FloatAttribute, IntAttribute, BoolAttribute, ListAttribute
|
||||||
|
from ..regex import URL_PATTERN
|
||||||
|
from ..exception.config import SettingValueError
|
||||||
|
|
||||||
|
|
||||||
class ProxAttribute(ListAttribute):
|
class ProxAttribute(ListAttribute):
|
||||||
@ -9,6 +14,21 @@ class ProxAttribute(ListAttribute):
|
|||||||
'ftp': value
|
'ftp': value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UrlListAttribute(ListAttribute):
|
||||||
|
def validate(self, value: str):
|
||||||
|
v = value.strip()
|
||||||
|
url = re.match(URL_PATTERN, v)
|
||||||
|
if v != url:
|
||||||
|
raise SettingValueError(
|
||||||
|
setting_name=self.name,
|
||||||
|
setting_value=v,
|
||||||
|
rule="has to be a valid url"
|
||||||
|
)
|
||||||
|
|
||||||
|
def single_object_from_element(self, value: str):
|
||||||
|
return urlparse(value)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ConnectionSection(Section):
|
class ConnectionSection(Section):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -43,6 +63,25 @@ class ConnectionSection(Section):
|
|||||||
value="0.3"
|
value="0.3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# INVIDIOUS INSTANCES LIST
|
||||||
|
self.INVIDIOUS_INSTANCE_LIST = UrlListAttribute(
|
||||||
|
name="invidious_instances",
|
||||||
|
description="This is a List, where you can define the invidious instances,\n"
|
||||||
|
"the youtube downloader should use.\n"
|
||||||
|
"Here is a list of active ones: https://docs.invidious.io/instances/\n"
|
||||||
|
"Instances that use cloudflare or have source code changes could cause issues.\n"
|
||||||
|
"Hidden instances (.onion) will only work, when setting 'tor=true'.",
|
||||||
|
value=[
|
||||||
|
"https://yt.artemislena.eu/",
|
||||||
|
"https://watch.thekitty.zone/",
|
||||||
|
"https://y.com.sb/"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
# INVIDIOUS PROXY
|
||||||
|
self.INVIDIOUS_PROXY_VIDEOS = BoolAttribute(
|
||||||
|
name="invidious_proxy_video",
|
||||||
|
)
|
||||||
|
|
||||||
self.attribute_list = [
|
self.attribute_list = [
|
||||||
self.USE_TOR,
|
self.USE_TOR,
|
||||||
self.TOR_PORT,
|
self.TOR_PORT,
|
||||||
|
2
src/music_kraken/utils/regex.py
Normal file
2
src/music_kraken/utils/regex.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
URL_PATTERN = 'https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user