mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-02 09:41:07 +00:00
configure fuzzines and snapshot, #build
Changed: - Added *fuzzy:* secondary keyword for search - Added take snapshot now button - Changed snapshot policy to 12pm TZ aware - Fixed channel page size validator > 0
This commit is contained in:
commit
32fc89f4e7
@ -262,4 +262,4 @@ CORS_ALLOW_HEADERS = list(default_headers) + [
|
|||||||
|
|
||||||
# TA application settings
|
# TA application settings
|
||||||
TA_UPSTREAM = "https://github.com/tubearchivist/tubearchivist"
|
TA_UPSTREAM = "https://github.com/tubearchivist/tubearchivist"
|
||||||
TA_VERSION = "v0.2.3"
|
TA_VERSION = "v0.2.4-unstable"
|
||||||
|
@ -107,8 +107,11 @@ class ElasticSnapshot:
|
|||||||
|
|
||||||
def _build_policy_data(self):
|
def _build_policy_data(self):
|
||||||
"""build policy dict from config"""
|
"""build policy dict from config"""
|
||||||
|
at_12 = datetime.now().replace(hour=12, minute=0, second=0)
|
||||||
|
hour = at_12.astimezone(ZoneInfo("UTC")).hour
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"schedule": "0 30 1 * * ?",
|
"schedule": f"0 0 {hour} * * ?",
|
||||||
"name": f"<{self.POLICY}_>",
|
"name": f"<{self.POLICY}_>",
|
||||||
"repository": self.REPO,
|
"repository": self.REPO,
|
||||||
"config": {
|
"config": {
|
||||||
|
@ -98,7 +98,9 @@ class ApplicationSettingsForm(forms.Form):
|
|||||||
("1", "enable cookie"),
|
("1", "enable cookie"),
|
||||||
]
|
]
|
||||||
|
|
||||||
subscriptions_channel_size = forms.IntegerField(required=False)
|
subscriptions_channel_size = forms.IntegerField(
|
||||||
|
required=False, min_value=1
|
||||||
|
)
|
||||||
downloads_limit_count = forms.IntegerField(required=False)
|
downloads_limit_count = forms.IntegerField(required=False)
|
||||||
downloads_limit_speed = forms.IntegerField(required=False)
|
downloads_limit_speed = forms.IntegerField(required=False)
|
||||||
downloads_throttledratelimit = forms.IntegerField(required=False)
|
downloads_throttledratelimit = forms.IntegerField(required=False)
|
||||||
|
@ -191,7 +191,7 @@ class SearchParser:
|
|||||||
|
|
||||||
def __init__(self, search_query):
|
def __init__(self, search_query):
|
||||||
self.query_words = search_query.lower().split()
|
self.query_words = search_query.lower().split()
|
||||||
self.query_map = False
|
self.query_map = {"term": [], "fuzzy": []}
|
||||||
self.append_to = "term"
|
self.append_to = "term"
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@ -214,11 +214,11 @@ class SearchParser:
|
|||||||
if ":" in first_word:
|
if ":" in first_word:
|
||||||
index_match, query_string = first_word.split(":")
|
index_match, query_string = first_word.split(":")
|
||||||
if index_match in key_word_map:
|
if index_match in key_word_map:
|
||||||
self.query_map = key_word_map.get(index_match)
|
self.query_map.update(key_word_map.get(index_match))
|
||||||
self.query_words[0] = query_string
|
self.query_words[0] = query_string
|
||||||
return index_match
|
return index_match
|
||||||
|
|
||||||
self.query_map = key_word_map.get("simple")
|
self.query_map.update(key_word_map.get("simple"))
|
||||||
print(f"query_map: {self.query_map}")
|
print(f"query_map: {self.query_map}")
|
||||||
|
|
||||||
return "simple"
|
return "simple"
|
||||||
@ -229,29 +229,24 @@ class SearchParser:
|
|||||||
return {
|
return {
|
||||||
"simple": {
|
"simple": {
|
||||||
"index": "ta_video,ta_channel,ta_playlist",
|
"index": "ta_video,ta_channel,ta_playlist",
|
||||||
"term": [],
|
|
||||||
},
|
},
|
||||||
"video": {
|
"video": {
|
||||||
"index": "ta_video",
|
"index": "ta_video",
|
||||||
"term": [],
|
|
||||||
"channel": [],
|
"channel": [],
|
||||||
"active": [],
|
"active": [],
|
||||||
},
|
},
|
||||||
"channel": {
|
"channel": {
|
||||||
"index": "ta_channel",
|
"index": "ta_channel",
|
||||||
"term": [],
|
|
||||||
"active": [],
|
"active": [],
|
||||||
"subscribed": [],
|
"subscribed": [],
|
||||||
},
|
},
|
||||||
"playlist": {
|
"playlist": {
|
||||||
"index": "ta_playlist",
|
"index": "ta_playlist",
|
||||||
"term": [],
|
|
||||||
"active": [],
|
"active": [],
|
||||||
"subscribed": [],
|
"subscribed": [],
|
||||||
},
|
},
|
||||||
"full": {
|
"full": {
|
||||||
"index": "ta_subtitle",
|
"index": "ta_subtitle",
|
||||||
"term": [],
|
|
||||||
"lang": [],
|
"lang": [],
|
||||||
"source": [],
|
"source": [],
|
||||||
},
|
},
|
||||||
@ -329,6 +324,20 @@ class QueryBuilder:
|
|||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
def _get_fuzzy(self):
|
||||||
|
"""return fuziness valuee"""
|
||||||
|
fuzzy_value = self.query_map.get("fuzzy", ["auto"])[0]
|
||||||
|
if fuzzy_value == "no":
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if not fuzzy_value.isdigit():
|
||||||
|
return "auto"
|
||||||
|
|
||||||
|
if int(fuzzy_value) > 2:
|
||||||
|
return "2"
|
||||||
|
|
||||||
|
return fuzzy_value
|
||||||
|
|
||||||
def _build_simple(self):
|
def _build_simple(self):
|
||||||
"""build simple cross index query"""
|
"""build simple cross index query"""
|
||||||
must_list = []
|
must_list = []
|
||||||
@ -339,7 +348,7 @@ class QueryBuilder:
|
|||||||
"multi_match": {
|
"multi_match": {
|
||||||
"query": term,
|
"query": term,
|
||||||
"type": "bool_prefix",
|
"type": "bool_prefix",
|
||||||
"fuzziness": "auto",
|
"fuzziness": self._get_fuzzy(),
|
||||||
"operator": "and",
|
"operator": "and",
|
||||||
"fields": [
|
"fields": [
|
||||||
"channel_name._2gram",
|
"channel_name._2gram",
|
||||||
@ -368,7 +377,7 @@ class QueryBuilder:
|
|||||||
"multi_match": {
|
"multi_match": {
|
||||||
"query": term,
|
"query": term,
|
||||||
"type": "bool_prefix",
|
"type": "bool_prefix",
|
||||||
"fuzziness": "auto",
|
"fuzziness": self._get_fuzzy(),
|
||||||
"operator": "and",
|
"operator": "and",
|
||||||
"fields": [
|
"fields": [
|
||||||
"title._2gram^2",
|
"title._2gram^2",
|
||||||
@ -390,7 +399,7 @@ class QueryBuilder:
|
|||||||
"multi_match": {
|
"multi_match": {
|
||||||
"query": channel,
|
"query": channel,
|
||||||
"type": "bool_prefix",
|
"type": "bool_prefix",
|
||||||
"fuzziness": "auto",
|
"fuzziness": self._get_fuzzy(),
|
||||||
"operator": "and",
|
"operator": "and",
|
||||||
"fields": [
|
"fields": [
|
||||||
"channel.channel_name._2gram",
|
"channel.channel_name._2gram",
|
||||||
@ -413,7 +422,7 @@ class QueryBuilder:
|
|||||||
"multi_match": {
|
"multi_match": {
|
||||||
"query": term,
|
"query": term,
|
||||||
"type": "bool_prefix",
|
"type": "bool_prefix",
|
||||||
"fuzziness": "auto",
|
"fuzziness": self._get_fuzzy(),
|
||||||
"operator": "and",
|
"operator": "and",
|
||||||
"fields": [
|
"fields": [
|
||||||
"channel_description",
|
"channel_description",
|
||||||
@ -445,7 +454,7 @@ class QueryBuilder:
|
|||||||
"multi_match": {
|
"multi_match": {
|
||||||
"query": term,
|
"query": term,
|
||||||
"type": "bool_prefix",
|
"type": "bool_prefix",
|
||||||
"fuzziness": "auto",
|
"fuzziness": self._get_fuzzy(),
|
||||||
"operator": "and",
|
"operator": "and",
|
||||||
"fields": [
|
"fields": [
|
||||||
"playlist_description",
|
"playlist_description",
|
||||||
@ -477,7 +486,7 @@ class QueryBuilder:
|
|||||||
"match": {
|
"match": {
|
||||||
"subtitle_line": {
|
"subtitle_line": {
|
||||||
"query": term,
|
"query": term,
|
||||||
"fuzziness": "auto",
|
"fuzziness": self._get_fuzzy(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
beautifulsoup4==4.11.1
|
beautifulsoup4==4.11.1
|
||||||
celery==5.2.7
|
celery==5.2.7
|
||||||
Django==4.1.2
|
Django==4.1.3
|
||||||
django-auth-ldap==4.1.0
|
django-auth-ldap==4.1.0
|
||||||
django-cors-headers==3.13.0
|
django-cors-headers==3.13.0
|
||||||
djangorestframework==3.14.0
|
djangorestframework==3.14.0
|
||||||
Pillow==9.2.0
|
Pillow==9.3.0
|
||||||
redis==4.3.4
|
redis==4.3.4
|
||||||
requests==2.28.1
|
requests==2.28.1
|
||||||
ryd-client==0.0.6
|
ryd-client==0.0.6
|
||||||
|
Loading…
Reference in New Issue
Block a user