Last active
February 13, 2024 18:20
-
-
Save FOBshippingpoint/7ca6686de1b16a08b86b5333c4231b06 to your computer and use it in GitHub Desktop.
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
use JSON::Fast; | |
run <curl https://ani.gamer.com.tw/animeVideo.php?sn=34245 -o temp>; | |
'temp'.IO.comb(/ '?sn=' \d+ '">' \d /) ==> map({ $_ ~~ /'?sn=' (\d+) .*/ }) | |
==> map(~*[0].Int) | |
==> unique() | |
==> sort() | |
==> my @sn-list; | |
'temp'.IO.unlink; | |
spurt 'sn_list.txt', @sn-list.join("\n"); | |
sub danmu-to-ffmpeg-script($sn, $ep) { | |
$sn.say; | |
$ep.say; | |
"".say; | |
run 'curl', '-X', 'POST', "-H='Content-Type: application/x-www-form-urlencoded; charset=UTF-8'", '-d', "sn=$sn", '-o', "ep$ep.json", '--', 'https://ani.gamer.com.tw/ajax/danmuGet.php'; | |
my @danmu := from-json "ep$ep.json".IO.slurp; | |
@danmu.elems.print; | |
say " danmu received."; | |
my $input = "$ep.mp4"; | |
my $output = 'output01.mp4'; | |
@danmu = grep { $_<text> ~~ m/ 笨蛋 | 八嘎 | 吧嘎 | 巴嘎 / }, @danmu; | |
for @danmu <-> $_ { | |
my $time = ($_<time> / 10).Int - 10; | |
$_ = "ffmpeg -ss $time -i $input -t 15 -c copy " ~ $ep ~ '_' ~ $output++ ~ ';'; | |
} | |
@danmu.elems.print; | |
say " danmu filtered."; | |
spurt "$ep.ps1", @danmu.join("\n") ~ "\n"; | |
} | |
my $i = '01'; | |
for 'sn_list.txt'.IO.lines { | |
danmu-to-ffmpeg-script($_, $i++); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment