superbrain-server 1.0.41 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/main.py +24 -0
- package/payload/fix.py +0 -25
- package/payload/test_init.py +0 -28
package/package.json
CHANGED
package/payload/main.py
CHANGED
|
@@ -826,6 +826,30 @@ def main():
|
|
|
826
826
|
# Extract structured data from summary for database
|
|
827
827
|
title, summary_text, tags, music, category = parse_summary(final_summary)
|
|
828
828
|
|
|
829
|
+
# OVERRIDE LLM MUSIC WITH DIRECT SHAZAM OUTPUT TO PRESERVE LINKS
|
|
830
|
+
if results.get('music_identification'):
|
|
831
|
+
for item in results['music_identification']:
|
|
832
|
+
out = item['output']
|
|
833
|
+
if 'Song:' in out:
|
|
834
|
+
song = [l.split('Song:')[1].strip() for l in out.split('\n') if 'Song:' in l][0]
|
|
835
|
+
artist_line = [l.split('Artist:')[1].strip() for l in out.split('\n') if 'Artist:' in l]
|
|
836
|
+
artist = artist_line[0] if artist_line else 'Unknown'
|
|
837
|
+
link = ""
|
|
838
|
+
spot_line = [l.split('Spotify:')[1].strip() for l in out.split('\n') if 'Spotify:' in l]
|
|
839
|
+
apple_line = [l.split('Apple Music:')[1].strip() for l in out.split('\n') if 'Apple Music:' in l]
|
|
840
|
+
if spot_line:
|
|
841
|
+
link = spot_line[0]
|
|
842
|
+
elif apple_line:
|
|
843
|
+
link = apple_line[0]
|
|
844
|
+
music = f"{song} by {artist}"
|
|
845
|
+
if link:
|
|
846
|
+
music += f" | {link}"
|
|
847
|
+
break
|
|
848
|
+
elif 'No match found' in out:
|
|
849
|
+
music = "No music identified"
|
|
850
|
+
break
|
|
851
|
+
|
|
852
|
+
|
|
829
853
|
# Get additional metadata from info.txt if available
|
|
830
854
|
username = ""
|
|
831
855
|
likes = 0
|
package/payload/fix.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
|
|
3
|
-
with open(r'd:\superbrain\backend\main.py', 'r', encoding='utf-8') as f:
|
|
4
|
-
code = f.read()
|
|
5
|
-
|
|
6
|
-
# Fix 1: _parse_field for TAGS was reading 📸 and no variable existed for tags init correctly in old code, wait, let's look at what was there.
|
|
7
|
-
code = code.replace(
|
|
8
|
-
'summary = _parse_field(summary_text, "📸", "TAGS")',
|
|
9
|
-
'summary = _parse_field(summary_text, "📸", "SUMMARY")\n raw_tags = _parse_field(summary_text, "🏷️", "TAGS")'
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
# Fix 2: inject music extraction
|
|
13
|
-
code = code.replace(
|
|
14
|
-
'# Category: grab first word/phrase',
|
|
15
|
-
'''music = _parse_field(summary_text, "🎵", "MUSIC")
|
|
16
|
-
if not music:
|
|
17
|
-
_mm = re.search(r'(?:^|\\n)\\s*\\*{0,2}MUSIC\\*{0,2}:?\\s*([^\\n]+)', summary_text, re.IGNORECASE)
|
|
18
|
-
if _mm:
|
|
19
|
-
music = _mm.group(1).strip()
|
|
20
|
-
|
|
21
|
-
# Category: grab first word/phrase'''
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
with open(r'd:\superbrain\backend\main.py', 'w', encoding='utf-8') as f:
|
|
25
|
-
f.write(code)
|
package/payload/test_init.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
import os
|
|
3
|
-
from instagram.instagram_downloader import download_instagram_content
|
|
4
|
-
from analyzers.music_identifier import identify_music
|
|
5
|
-
|
|
6
|
-
async def test():
|
|
7
|
-
print('Downloading...')
|
|
8
|
-
try:
|
|
9
|
-
url = 'https://www.instagram.com/reel/DWGy0xKk0DV/?igsh=bDJ5ZHozOHh6dHFr'
|
|
10
|
-
folder = download_instagram_content(url)
|
|
11
|
-
print('Downloaded to:', folder)
|
|
12
|
-
# Find the .mp3 file in the folder
|
|
13
|
-
audio_path = None
|
|
14
|
-
for root, dirs, files in os.walk(folder):
|
|
15
|
-
for file in files:
|
|
16
|
-
if file.endswith('.mp3'):
|
|
17
|
-
audio_path = os.path.join(root, file)
|
|
18
|
-
break
|
|
19
|
-
print('Identifying music on:', audio_path)
|
|
20
|
-
music_res = await identify_music(audio_path)
|
|
21
|
-
print('Music Result:', music_res)
|
|
22
|
-
except Exception as e:
|
|
23
|
-
print('Error:', e)
|
|
24
|
-
import traceback
|
|
25
|
-
traceback.print_exc()
|
|
26
|
-
|
|
27
|
-
if __name__ == '__main__':
|
|
28
|
-
asyncio.run(test())
|