Last active
March 18, 2023 17:30
-
-
Save Dobby233Liu/381f871597afc0afedf5de24c328c2df to your computer and use it in GitHub Desktop.
stuff ive done to fix my "awesome random music" bookmark folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prerequisite | |
pip install git+https://github.com/FlyingWolFox/Netscape-Bookmarks-File-Parser.git | |
python # Snippet 1 | |
cd ~/storage/downloads | |
mkdir tmp/th && cd tmp/th | |
# Download descs | |
yt-dlp --skip-download --write-description --no-mtime $(cat ../../bookmarks_pure.txt) | |
# Check what is not from YAL | |
# incompetech.com is for Kevin Macleod | |
ack -rL "YouTube Audio Library|incompetech.com" > ~/storage/downloads/index.txt | |
# You can do extra checks | |
# ack "Routenote" > ~/storage/downloads/index_t.txt | |
# ack "Bobby Cole" > ~/storage/downloads/index_t.txt | |
# ack "tech.com" > ~/storage/downloads/index_t.txt | |
cd ../.. | |
python # snippet 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Snippet 1: Generate bookmarks_pure.txt from bookmark export | |
import os | |
from NetscapeBookmarksFileParser import * | |
from NetscapeBookmarksFileParser import parser | |
def find(lst, condition): | |
for elem in lst: | |
if condition(elem): | |
yield elem | |
rd = os.path.expanduser("~/storage/downloads") | |
with open(rd + "/bookmarks_snap_check.html") as f: | |
bookmarks = NetscapeBookmarksFile(f).parse() | |
arm = next(find(bookmarks.bookmarks.children, lambda x: x.name == "awesome random music")) | |
with open(rd + "/bookmarks_pure.txt","w") as r: | |
for i in arm.items: | |
if isinstance(i, BookmarkFolder): | |
continue | |
# Suggestion: ignore bookmarks with certain keywords | |
# such as: [FIXME [NO | |
print(i.href, file=r) | |
exit() | |
# Snippet 2: Get videos that are not indexed by yt-dlp | |
# You should save the output of the tool and grep that instead | |
import re | |
import os | |
fptrn = "[^\[]+\[([A-Za-z0-9_\-]+)\].description" | |
uptrn = "https://m.youtube.com/watch\?v=([A-Za-z0-9_\-]+)$" | |
vids = [] | |
with open("bookmarks_pure.txt", "r") as bms: | |
for i in bms.readlines(): | |
if i.strip() == "": | |
continue | |
r = re.findall(uptrn, i) | |
if len(r) < 1: | |
assert False, i | |
vids.append(r[0].strip()) | |
avids = [] | |
for i in os.listdir("tmp/th"): | |
id = re.findall(fptrn, i) | |
if len(id) < 1: | |
print(i) | |
continue | |
avids.append(id[0]) | |
for i in vids: | |
if i not in avids: | |
print(i) | |
exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tips on discovering songs for the folder! | |
=== Where to find music/video === | |
- Videos | |
- Recommendations | |
- Search | |
- Audio Library page | |
https://www.youtube.com/audiolibrary | |
- NCA content farm channels | |
They could have playlists of songs, you can check one by one | |
- Identification services | |
You can upload unknown audio to let it identify | |
=== Stuff to look for === | |
- Is channel auto-generated? | |
Some videos are assigned to actual channels | |
- "- Topic" suffix in the uploader channel's name | |
- A localized "Channel auto-generated by YouTube" link in the channel's description page | |
- Thumbnail | |
Should have YAL written on it | |
Square version has dark green padding OUTSIDE OF THE VIDEO/WHEN NOT PLAYED, properly cropped IN THE VIDEO | |
- Description keywords | |
- Provided to YouTube by | |
- YouTube Audio Library | |
- incompetech.com | |
for Kevin Macleod songs | |
=== Fixme tags === | |
In the bookmark name, put these tags into a bracket after the song's title, add additional notes if needed | |
FIXME | |
YAL LINK | |
(Not a YouTube Audio Library auto-generated video, but song could be in YAL) | |
? (not sure if this is in YAL) | |
stolen[?] (very likely a bad upload) | |
NO YAL LINK[?] | |
(Not a YAL video, and song is not in YAL) | |
IT (probably not released on YAL yet) (question mark applies) | |
DzM (most likely won't be released on YAL) | |
BC (probably not even a NCA) (question mark applies) | |
DEADLINK | |
(Leads to a unplayable video) | |
=== Misc. info === | |
- Strip unnecessary url params from links you put in the folder. | |
- Identification services can be inaccurate. | |
If you don't see a result's artist indexed in YAL, it would almost certainly mean that | |
the song that the service found was NOT the actual one. | |
Try finding a reupload on YouTube. There may be hints to the actual song if you're lucky. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment