mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-21 09:07:02 +01:00
cleanup
This commit is contained in:
@@ -72,8 +72,8 @@ async def get_task(event, client, dvm_config):
|
|||||||
[EventDefinitions.KIND_NIP90_RESULT_EXTRACT_TEXT,
|
[EventDefinitions.KIND_NIP90_RESULT_EXTRACT_TEXT,
|
||||||
EventDefinitions.KIND_NIP90_RESULT_TRANSLATE_TEXT,
|
EventDefinitions.KIND_NIP90_RESULT_TRANSLATE_TEXT,
|
||||||
EventDefinitions.KIND_NIP90_RESULT_SUMMARIZE_TEXT],
|
EventDefinitions.KIND_NIP90_RESULT_SUMMARIZE_TEXT],
|
||||||
client=client,
|
client=client,
|
||||||
dvm_config=dvm_config)
|
dvm_config=dvm_config)
|
||||||
if evt is not None:
|
if evt is not None:
|
||||||
file_type = check_url_is_readable(evt.content())
|
file_type = check_url_is_readable(evt.content())
|
||||||
if file_type == "image":
|
if file_type == "image":
|
||||||
@@ -111,7 +111,7 @@ def is_input_supported_generic(tags, client, dvm_config) -> bool:
|
|||||||
else:
|
else:
|
||||||
input_value = tag.as_vec()[1]
|
input_value = tag.as_vec()[1]
|
||||||
input_type = tag.as_vec()[2]
|
input_type = tag.as_vec()[2]
|
||||||
#if input_type == "event":
|
# if input_type == "event":
|
||||||
# evt = get_event_by_id(input_value, client=client, config=dvm_config)
|
# evt = get_event_by_id(input_value, client=client, config=dvm_config)
|
||||||
# if evt is None:
|
# if evt is None:
|
||||||
# print("Event not found")
|
# print("Event not found")
|
||||||
@@ -135,8 +135,8 @@ async def check_task_is_supported(event: Event, client, config=None):
|
|||||||
|
|
||||||
# See if current dvm supports the task
|
# See if current dvm supports the task
|
||||||
task = await get_task(event, client=client, dvm_config=dvm_config)
|
task = await get_task(event, client=client, dvm_config=dvm_config)
|
||||||
# if task not in (x.TASK for x in dvm_config.SUPPORTED_DVMS) and not task == "generic":
|
# if task not in (x.TASK for x in dvm_config.SUPPORTED_DVMS) and not task == "generic":
|
||||||
# return False, task
|
# return False, task
|
||||||
# See if current dvm can handle input for given task
|
# See if current dvm can handle input for given task
|
||||||
for dvm in dvm_config.SUPPORTED_DVMS:
|
for dvm in dvm_config.SUPPORTED_DVMS:
|
||||||
if dvm.TASK == task:
|
if dvm.TASK == task:
|
||||||
@@ -161,16 +161,16 @@ def check_url_is_readable(url):
|
|||||||
content_type = req.headers['content-type']
|
content_type = req.headers['content-type']
|
||||||
if content_type == 'audio/x-wav' or str(url).endswith(".wav") or content_type == 'audio/mpeg' or str(
|
if content_type == 'audio/x-wav' or str(url).endswith(".wav") or content_type == 'audio/mpeg' or str(
|
||||||
url).endswith(
|
url).endswith(
|
||||||
".mp3") or content_type == 'audio/ogg' or str(url).endswith(".ogg"):
|
".mp3") or content_type == 'audio/ogg' or str(url).endswith(".ogg"):
|
||||||
return "audio"
|
return "audio"
|
||||||
elif (content_type == 'image/png' or str(url).endswith(".png") or content_type == 'image/jpg' or str(
|
elif (content_type == 'image/png' or str(url).endswith(".png") or content_type == 'image/jpg' or str(
|
||||||
url).endswith(
|
url).endswith(
|
||||||
".jpg") or content_type == 'image/jpeg' or str(url).endswith(".jpeg") or content_type == 'image/png' or
|
".jpg") or content_type == 'image/jpeg' or str(url).endswith(".jpeg") or content_type == 'image/png' or
|
||||||
str(url).endswith(".png")):
|
str(url).endswith(".png")):
|
||||||
return "image"
|
return "image"
|
||||||
elif content_type == 'video/mp4' or str(url).endswith(".mp4") or content_type == 'video/avi' or str(
|
elif content_type == 'video/mp4' or str(url).endswith(".mp4") or content_type == 'video/avi' or str(
|
||||||
url).endswith(
|
url).endswith(
|
||||||
".avi") or content_type == 'video/mov' or str(url).endswith(".mov"):
|
".avi") or content_type == 'video/mov' or str(url).endswith(".mov"):
|
||||||
return "video"
|
return "video"
|
||||||
elif (str(url)).endswith(".pdf"):
|
elif (str(url)).endswith(".pdf"):
|
||||||
return "pdf"
|
return "pdf"
|
||||||
@@ -184,7 +184,7 @@ def check_url_is_readable(url):
|
|||||||
def get_amount_per_task(task, dvm_config, duration=1):
|
def get_amount_per_task(task, dvm_config, duration=1):
|
||||||
# duration is either static 1 (for images etc) or in seconds by default (e.g. audio/video)
|
# duration is either static 1 (for images etc) or in seconds by default (e.g. audio/video)
|
||||||
for dvm in dvm_config.SUPPORTED_DVMS: # this is currently just one
|
for dvm in dvm_config.SUPPORTED_DVMS: # this is currently just one
|
||||||
if dvm.TASK == task or dvm.TASK == "generic":
|
if dvm.TASK == task or dvm.TASK == "generic":
|
||||||
amount = dvm.FIX_COST + (dvm.PER_UNIT_COST * duration)
|
amount = dvm.FIX_COST + (dvm.PER_UNIT_COST * duration)
|
||||||
return amount
|
return amount
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from nostr_dvm.utils.database_utils import get_or_add_user
|
from nostr_dvm.utils.database_utils import get_or_add_user
|
||||||
@@ -10,7 +9,6 @@ from nostr_dvm.utils.zap_utils import create_bolt11_ln_bits, create_bolt11_lud16
|
|||||||
BASE_URL = "https://mint.minibits.cash/Bitcoin"
|
BASE_URL = "https://mint.minibits.cash/Bitcoin"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parse_cashu(cashu_token: str):
|
def parse_cashu(cashu_token: str):
|
||||||
try:
|
try:
|
||||||
prefix = "cashuA"
|
prefix = "cashuA"
|
||||||
|
|||||||
Reference in New Issue
Block a user