mirror of
https://github.com/searxng/searxng.git
synced 2026-06-12 04:47:49 +02:00
[mod] odysee: move format_duration helper into utils.py
This commit is contained in:
+1
-10
@@ -4,7 +4,6 @@
|
|||||||
.. _Odysee: https://github.com/OdyseeTeam/odysee-frontend
|
.. _Odysee: https://github.com/OdyseeTeam/odysee-frontend
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
@@ -12,6 +11,7 @@ import babel
|
|||||||
|
|
||||||
from searx.enginelib.traits import EngineTraits
|
from searx.enginelib.traits import EngineTraits
|
||||||
from searx.locales import language_tag
|
from searx.locales import language_tag
|
||||||
|
from searx.utils import format_duration
|
||||||
|
|
||||||
# Engine metadata
|
# Engine metadata
|
||||||
about = {
|
about = {
|
||||||
@@ -61,15 +61,6 @@ def request(query, params):
|
|||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
# Format the video duration
|
|
||||||
def format_duration(duration):
|
|
||||||
seconds = int(duration)
|
|
||||||
length = time.gmtime(seconds)
|
|
||||||
if length.tm_hour:
|
|
||||||
return time.strftime("%H:%M:%S", length)
|
|
||||||
return time.strftime("%M:%S", length)
|
|
||||||
|
|
||||||
|
|
||||||
def response(resp):
|
def response(resp):
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
results = []
|
results = []
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
"""Utility functions for the engines"""
|
"""Utility functions for the engines"""
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import importlib
|
import importlib
|
||||||
@@ -809,3 +810,12 @@ def parse_duration_string(duration_str: str) -> timedelta | None:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
# Format the video duration
|
||||||
|
def format_duration(duration):
|
||||||
|
seconds = int(duration)
|
||||||
|
length = time.gmtime(seconds)
|
||||||
|
if length.tm_hour:
|
||||||
|
return time.strftime("%H:%M:%S", length)
|
||||||
|
return time.strftime("%M:%S", length)
|
||||||
|
|||||||
Reference in New Issue
Block a user