Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多行同时间的LRC在A25无法正常使用 #1

Closed
Oyami-Srk opened this issue Nov 9, 2019 · 3 comments
Closed

多行同时间的LRC在A25无法正常使用 #1

Oyami-Srk opened this issue Nov 9, 2019 · 3 comments

Comments

@Oyami-Srk
Copy link

例:

[00:00.87]We have always stood on the borderland.
[00:03.33]我们始终踱步于境戒线之上
[00:03.33]I'm enjoying the view from here.
[00:06.17]皆因此境风景独好
[00:06.17]Eeny, meeny, miny, moe…much the same
[00:11.51]一,二,三,四...其实都一样

只会显示第一句相同时间的歌词,以上显示效果如下:

We have always stood on the borderland.
我们始终踱步于境戒线之上
皆因此境风景独好
一,二,三,四...其实都一样

且翻译和原歌词时间不对应

@Oyami-Srk
Copy link
Author

Oyami-Srk commented Nov 9, 2019

#!python3
import re
import os
import sys

r = re.compile(r'^(\[\d*:\d*\.\d*\])(.*)$')

in_dir = sys.argv[-2]
out_dir = sys.argv[-1]

DEBUG = True


def proc(fn: str, out_dir: str):
    with open(fn, 'r') as f:
        ls = f.readlines()
        lrc = ""
        lines = len(ls)
        i = 0
        tup = []
        while True:
            c = r.findall(ls[i])[0]
            n = r.findall(ls[i + 1])[0]
            if c[0] == n[0]:
                tup.append((i, i + 1))
            i = i + 1
            if i >= lines - 1:
                break
        tn = 0
        i = 0
        if DEBUG:
            print(tup)
        while True:
            if tn < len(tup) and tup[tn][0] == i:
                lrc += r.findall(ls[i])[0][1] + '\n'
            elif tn < len(tup) and tup[tn][1] == i:
                if i == lines - 1:
                    break
                if r.findall(ls[i])[0][1] == '':
                    lrc += '\n'
                else:
                    lrc += ls[i].strip('\n') + ' \\ '
                tn += 1
            else:
                if tn < len(tup) and i + 1 == tup[tn][0]:
                    lrc += ls[i].strip('\n') + ' \\ '
                else:
                    lrc += ls[i]
            i = i + 1
            if i >= lines:
                break

        if not DEBUG:
            with open(out_dir + "/" + os.path.basename(fn), "w") as o:
                o.write(lrc)
        else:
            print(lrc)


if __name__ == "__main__":
    if not DEBUG:
        fs = os.listdir(in_dir)
        for f in fs:
            f = in_dir + '/' + f
            if not os.path.isfile(f):
                continue
            if os.path.splitext(f)[1] != '.lrc':
                continue
            if os.path.getsize(f) == 0:
                continue
            print(f)
            proc(f, out_dir)
    else:
        proc(in_dir + '/' + '722013.lrc', '')

写了一个脚本合并原句和翻译,但是对于一些特殊情况如歌曲ID722013的歌词存在Bug

@Oyami-Srk
Copy link
Author

意识到了在A25这种小屏机器上我看个锤子的歌词

LynMoe pushed a commit that referenced this issue Jun 26, 2020
@LynMoe
Copy link
Member

LynMoe commented Jun 26, 2020

非常抱歉不小心 unwatch 了这个项目导致看不到 issue 提醒

正好使用 Node 重构了一遍,看到 issue 之后就加了这个功能,可以尝试一下

@LynMoe LynMoe closed this as completed Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants