这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions extract_songs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
from typing import Optional, Union, List
from TexSoup import TexSoup
import re
import json
import os
from glob import glob
from dataclasses import dataclass, asdict
from tqdm import tqdm

from TexSoup.data import TexNamedEnv, BraceGroup, TexCmd, TexMathModeEnv, TexNode

Expand Down Expand Up @@ -543,9 +548,6 @@ def _extract_notes_from_content(nodes):
return notes


from dataclasses import dataclass


@dataclass
class SongInfo:
name: str
Expand Down Expand Up @@ -675,16 +677,28 @@ def parse_tex(content: Union[str, bytes]) -> List[SongInfo]:
]


from glob import glob
from dataclasses import asdict
import json
from tqdm import tqdm
import os

# WHITELIST = ("eino", "")
WHITELIST = ("",)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file isnt formatted properly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the formatting issues by consolidating the misplaced imports and running Black formatter. All imports are now properly organized at the top of the file. (415c94a)



def song_contains_todo(song: SongInfo) -> bool:
"""Check if a song contains 'TODO' in any of its fields."""
fields_to_check = [
song.name,
song.melody,
song.composer,
song.arranger,
song.lyrics,
song.notes,
]

for field in fields_to_check:
if field and "TODO" in field:
return True

return False


def main():
songs = []
failed_files = []
Expand Down Expand Up @@ -718,7 +732,9 @@ def main():
# Process each song (main song and subsongs)
for song in parsed_songs:
if song.name != "Parse Error":
songs.append(asdict(song))
# Filter out songs that contain TODO in any field
if not song_contains_todo(song):
songs.append(asdict(song))
else:
failed_files.append(pa)
break # If any song failed, mark the whole file as failed
Expand Down
Loading