Skip to content

Commit

Permalink
more fixes related to deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
believethehype committed Dec 18, 2023
1 parent ba31826 commit 39821ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
38 changes: 18 additions & 20 deletions nostr_dvm/utils/mediasource_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from decord import AudioReader, cpu
import requests
from nostr_dvm.utils.nostr_utils import get_event_by_id
from nostr_dvm.utils.scrapper.media_scrapper import OvercastDownload, XitterDownload, TiktokDownloadAll, \
InstagramDownload, YouTubeDownload


def input_data_file_duration(event, dvm_config, client, start=0, end=0):
#print("[" + dvm_config.NIP89.NAME + "] Getting Duration of the Media file..")
# print("[" + dvm_config.NIP89.NAME + "] Getting Duration of the Media file..")
input_value = ""
input_type = ""
for tag in event.tags():
Expand All @@ -18,7 +20,7 @@ def input_data_file_duration(event, dvm_config, client, start=0, end=0):
input_type = tag.as_vec()[2]

if input_type == "text":
#For now, ingore length of any text, just return 1.
# For now, ingore length of any text, just return 1.
return 1

if input_type == "event": # NIP94 event
Expand Down Expand Up @@ -52,7 +54,8 @@ def input_data_file_duration(event, dvm_config, client, start=0, end=0):
return 1


def organize_input_media_data(input_value, input_type, start, end, dvm_config, client, process=True, media_format="audio/mp3") -> str:
def organize_input_media_data(input_value, input_type, start, end, dvm_config, client, process=True,
media_format="audio/mp3") -> str:
if input_type == "event": # NIP94 event
evt = get_event_by_id(input_value, client=client, config=dvm_config)
if evt is not None:
Expand Down Expand Up @@ -209,7 +212,7 @@ def get_overcast(input_value, start, end):
print("Found overcast.fm Link.. downloading")
start_time = start
end_time = end
downloadOvercast(input_value, filename)
download_overcast(input_value, filename)
finaltag = str(input_value).replace("https://overcast.fm/", "").split('/')
if start == 0.0:
if len(finaltag) > 1:
Expand All @@ -227,7 +230,7 @@ def get_overcast(input_value, start, end):
def get_TikTok(input_value, start, end):
filepath = os.path.abspath(os.curdir + r'/outputs/')
try:
filename = downloadTikTok(input_value, filepath)
filename = download_tik_tok(input_value, filepath)
print(filename)
except Exception as e:
print(e)
Expand All @@ -238,7 +241,7 @@ def get_TikTok(input_value, start, end):
def get_Instagram(input_value, start, end):
filepath = os.path.abspath(os.curdir + r'/outputs/')
try:
filename = downloadInstagram(input_value, filepath)
filename = download_instagram(input_value, filepath)
print(filename)
except Exception as e:
print(e)
Expand All @@ -250,7 +253,7 @@ def get_Twitter(input_value, start, end):
filepath = os.path.abspath(os.curdir) + r'/outputs/'
cleanlink = str(input_value).replace("twitter.com", "x.com")
try:
filename = downloadTwitter(cleanlink, filepath)
filename = download_twitter(cleanlink, filepath)
except Exception as e:
print(e)
return "", start, end
Expand All @@ -259,9 +262,10 @@ def get_Twitter(input_value, start, end):

def get_youtube(input_value, start, end, audioonly=True):
filepath = os.path.abspath(os.curdir) + r'/outputs/'
print(filepath)
filename = ""
try:
filename = downloadYouTube(input_value, filepath, audioonly)
filename = download_youtube(input_value, filepath, audioonly)

except Exception as e:
print("Youtube " + str(e))
Expand Down Expand Up @@ -331,31 +335,25 @@ def get_media_link(url) -> (str, str):
return None, None


def downloadOvercast(source_url, target_location):
from nostr_dvm.utils.scrapper.media_scrapper import OvercastDownload
def download_overcast(source_url, target_location):
result = OvercastDownload(source_url, target_location)
return result


def downloadTwitter(videourl, path):
from nostr_dvm.utils.scrapper.media_scrapper import XitterDownload
def download_twitter(videourl, path):
result = XitterDownload(videourl, path + "x.mp4")
return result


def downloadTikTok(videourl, path):
from nostr_dvm.utils.scrapper.media_scrapper import TiktokDownloadAll
def download_tik_tok(videourl, path):
result = TiktokDownloadAll([videourl], path)
return result


def downloadInstagram(videourl, path):
from nostr_dvm.utils.scrapper.media_scrapper import InstagramDownload
def download_instagram(videourl, path):
result = InstagramDownload(videourl, "insta", path)
return result


def downloadYouTube(link, path, audioonly=True):
from nostr_dvm.utils.scrapper.media_scrapper import YouTubeDownload
result = YouTubeDownload(link, path, audio_only=audioonly)
return result
def download_youtube(link, path, audioonly=True):
return YouTubeDownload(link, path, audio_only=audioonly)
1 change: 0 additions & 1 deletion nostr_dvm/utils/scrapper/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from dvm import DVM
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '0.0.6'
VERSION = '0.0.7'
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. '
'This is an early stage release. Interfaces might change/brick')
Expand Down Expand Up @@ -30,7 +30,9 @@
"instaloader==4.10.1",
"pytube==15.0.0",
"moviepy==2.0.0.dev2",
"zipp==3.17.0"
"zipp==3.17.0",
"urllib3==2.1.0",
"typing_extensions==4.8.0"
],
keywords=['nostr', 'nip90', 'dvm', 'data vending machine'],
url="https://github.com/believethehype/nostrdvm",
Expand Down

0 comments on commit 39821ac

Please sign in to comment.