- Introduce `app.py` as the main application file to handle shitpost scanning. - Create `config.py` for configuration settings including scan paths and file types. - Implement database models in `Models.py` for shitposts, songs, speech outputs, and tags. - Add database creation logic in `db.py`. - Develop various scanners (`OcrScanner.py`, `SongScanner.py`, `SpeechScanner.py`, `TagScanner.py`) for extracting information from shitposts. - Implement utility functions in `dateExtractor.py` and `shitpostFactory.py` for handling file metadata and creating shitpost objects. - Include a `pyproject.toml` for project dependencies and configuration.
22 lines
812 B
Python
22 lines
812 B
Python
from time import time
|
|
from config import VIDEO_FILETYPES
|
|
from db.Models import Shitpost, SongMatch
|
|
import subprocess
|
|
import threading
|
|
|
|
def extractSong(shitpost: Shitpost,lock:threading.Lock):
|
|
t1 = time()
|
|
print(f"\tstarting to extract song for {shitpost.hash[:4]} aka {shitpost.path}")
|
|
|
|
if shitpost.song is None and shitpost.file_type in VIDEO_FILETYPES:
|
|
result = subprocess.run(['songrec', 'recognize', shitpost.path], capture_output=True, text=True)
|
|
artist = result.stdout.split("-")[0][:-1]
|
|
songname = result.stdout.split("-")[1][0:]
|
|
songmatch = SongMatch(
|
|
song_name=songname,
|
|
artist_name=artist
|
|
)
|
|
with lock:
|
|
shitpost.song = songmatch
|
|
print(f"\tsong extraced for {shitpost.hash[:4]} in :{time()-t1} ")
|