Last active
June 15, 2023 17:15
-
-
Save rexim/535027b78c98452778e483b034c3793c to your computer and use it in GitHub Desktop.
Epic Screencast Adder PauseChamp
This file contains hidden or 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
module Main where | |
import qualified Data.Text as T | |
import qualified Data.Text.IO as T | |
import System.Directory | |
import Data.Functor | |
-- NOTE: Yt stands for YouTube. It's a YouTube link to the video | |
type Yt = T.Text | |
ytId :: Yt -> T.Text | |
ytId = head . T.splitOn "&" . (!! 1) . T.splitOn "?v=" | |
ytThumbnail :: Yt -> T.Text | |
ytThumbnail yt = "http://i3.ytimg.com/vi/" <> ytId yt <> "/hqdefault.jpg" | |
ytMarkdownLink :: Yt -> T.Text | |
ytMarkdownLink yt = "[](" <> yt <> ")" | |
ytMarkdownSection :: Yt -> [T.Text] | |
ytMarkdownSection yt = ["## Screencast", "", ytMarkdownLink yt] | |
-- NOTE: Ep stands for Episode | |
type Ep = T.Text | |
epFolder :: Ep -> IO FilePath | |
epFolder ep = head . filter (\dirPath -> ep `T.isPrefixOf` T.pack dirPath) <$> listDirectory "." | |
epREADME :: Ep -> IO FilePath | |
epREADME ep = (<> "/README.md") <$> epFolder ep | |
-- NOTE: Sc stands for Screencast | |
data Sc = Sc { scEp :: Ep, scYt :: Yt } deriving Show | |
parseSc :: T.Text -> Sc | |
parseSc s = Sc a b | |
where [a, b] = T.splitOn ": " s | |
addSc :: Sc -> IO () | |
addSc (Sc ep yt) = do | |
readmePath <- epREADME ep | |
readme <- T.lines <$> T.readFile readmePath | |
let section = ytMarkdownSection yt | |
T.writeFile readmePath $ T.unlines $ [head readme, ""] <> section <> tail readme | |
scs :: IO [Sc] | |
scs = map parseSc . T.lines <$> T.readFile "./screencasts.txt" | |
main :: IO () | |
main = scs >>= mapM_ addSc |
This file contains hidden or 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
03: https://www.youtube.com/watch?v=mlth0Bn18Vs&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=700s | |
04: https://www.youtube.com/watch?v=cvvNfuS4BwI&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=755s | |
05: https://www.youtube.com/watch?v=vVjNyY2jkqg&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=829s | |
06: https://www.youtube.com/watch?v=vVjNyY2jkqg&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=3970s | |
07: https://www.youtube.com/watch?v=FXPmwFubyDE&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=713s | |
08: https://www.youtube.com/watch?v=8aYjw62hxTY&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=752s | |
09: https://www.youtube.com/watch?v=a8vogmPtlXE&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=778s | |
10: https://www.youtube.com/watch?v=lHzbWWjdloM&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=709s | |
11: https://www.youtube.com/watch?v=lHzbWWjdloM&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=4680s | |
12: https://www.youtube.com/watch?v=R00JE6QRbno&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=742s | |
13: https://www.youtube.com/watch?v=i2bya8kNXjw&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=708s | |
14: https://www.youtube.com/watch?v=95ooXiwVeMM&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P | |
15: https://www.youtube.com/watch?v=ech9Re2bi_E&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=791s | |
16: https://www.youtube.com/watch?v=xb-yZhokKSw&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=807s | |
17: https://www.youtube.com/watch?v=rKPG4bGQLGk&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=734s | |
18: https://www.youtube.com/watch?v=gGDuoey_TnE&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=777s | |
19: https://www.youtube.com/watch?v=6lFNgR5DkFg&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=740s | |
20: https://www.youtube.com/watch?v=vvvO8QQtW7Q&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=688s | |
21: https://www.youtube.com/watch?v=tP98VjF9Ljo&list=PLpM-Dvs8t0Vba3v-9lweHuomr0DPhdX6P&t=730s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment