Created
July 20, 2023 01:14
-
-
Save dtlnor/d81d1ed1293c0b4bb85319895340e5c7 to your computer and use it in GitHub Desktop.
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
ts=""" | |
1 . 08:01 回る空うさぎ/Orangestar | |
2 . 13:03 アルジャーノン/ヨルシカ | |
3 . 19:43 背景、夏に溺れる/ヨルシカ | |
4 . 26:20 友達の詩/中村中 | |
5 . 32:48 me me she / RADWIMPS | |
6 . 38:28 シンデレラボーイ/Saucy Dog | |
7 . 43:04 Everything / MISIA | |
8 . 51:05 逢いたくていま/MISIA | |
9 . 54:41 奏/スキマスイッチ | |
10. 1:01:51 secret base ~君がくれたもの~ /ZONE | |
11. 1:08:46 Time goes by / Every Little Thing | |
12. 1:12:45 明日への手紙/手嶌葵 | |
13. 1:18:39 さよならの夏/手嶌葵 | |
""" | |
import re | |
songs = ts.strip().splitlines() | |
dialogue_list = "" | |
out_with_next_ts = True | |
for song in songs: | |
re_ts_p = r"\d+:\d+:\d+\s|\d+:\d+\s" | |
result = re.findall(re_ts_p, song) | |
if not result: | |
print("skip this: "+song) | |
continue | |
this_ts = result[0].strip() | |
title = song.split(this_ts)[1].strip() | |
this_end_ts = this_ts | |
if len(result) > 1: | |
this_end_ts = result[1].strip() | |
title = title.split(this_end_ts)[1].strip() | |
song_name = "" | |
splitter = '/' | |
# splitter = ' ' | |
if splitter in title : | |
song_name = title.split(splitter)[0].strip() | |
author = title.split(splitter)[1].strip() | |
elif '\\' in title: | |
song_name = title.split('\\')[0].strip() | |
author = title.split('\\')[1].strip() | |
else: | |
song_name = title | |
if out_with_next_ts: | |
dialogue = f'Dialogue: 0,{this_end_ts},{this_end_ts},Default,,0,0,0,,out\nDialogue: 0,{this_ts},{this_ts},Default,,0,0,0,,{song_name}\n' | |
else: | |
dialogue = f'Dialogue: 0,{this_ts},{this_end_ts},Default,,0,0,0,,{song_name}\nDialogue: 0,{this_end_ts},{this_end_ts},Default,,0,0,0,,out\n' | |
dialogue_list = dialogue_list + dialogue | |
print(dialogue_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment