Skip to content

Instantly share code, notes, and snippets.

@yzAlvin
Created May 9, 2022 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yzAlvin/13426630e7b05e7bb2b9919bd55c0121 to your computer and use it in GitHub Desktop.
Save yzAlvin/13426630e7b05e7bb2b9919bd55c0121 to your computer and use it in GitHub Desktop.
SlipySlidy Playlist Scraper
import re
from pytube import Playlist
from pytube import YouTube
import jsonpickle
from dataclasses import dataclass
@dataclass
class Metadata:
albumArtist: str
artist: str
title: str
year: str
@dataclass
class Source:
client: str
date: str
structure: str
version: str
@dataclass
class Song:
description: str
filename: str
mark: str
metadata: Metadata
source: Source
youtube: str
url = "https://www.youtube.com/playlist?list=PLARr36qkoiWbhGZEZDvgv6F5vfRMR79_q"
playlist = Playlist(url)
playlist._video_regex = re.compile(r"\"url\":\"(/watch\?v=[\w-]*)")
f = open("Bgm_MapleStory2.json", "a")
for url in playlist.video_urls:
youtube = url.split("https://www.youtube.com/watch?v=")[1]
yt = YouTube(url)
description = yt.title.split("[MapleStory 2 BGM] ")[1]
filename = "".join(description.split())
mark = filename
date = yt.publish_date.date()
metadata = Metadata("Wizet", "StudioEIM", description, f'{date.year}')
source = Source("MS2", date, "Bgm_MapleStory2", "1.0")
song = Song(description, filename, mark, metadata, source, youtube)
songJson = jsonpickle.encode(song, unpicklable=False)
print(songJson)
f.write(f'{songJson},')
f.close()
@yzAlvin
Copy link
Author

yzAlvin commented May 9, 2022

scrape https://www.youtube.com/user/SlipySlidy playlist and write to json format in https://github.com/maplestory-music/maplebgm-db

need to do some manual work to make it a json array and format nicely 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment