Comments (22)
Yes, the id gets ignored. I don't got any problem. This is my result: https://pastebin.com/KKuXYWYx
from pylrc.
Nvm,
>>> f = open('/d/Downloads/Lovelyz - WoW! 3.srt', 'w')
>>> f.write(srt)
4286
>>> f.close()
worked.
from pylrc.
I think the example is wrong. If you look into this file, you can see, that only LyricLines got the shift method. You can simply iterate over the Lyrics object to shift each line
from pylrc.
Thanks for the quick response, how does one iterate over the Lyrics object?
from pylrc.
For example like this:
for sub in pylrc.parse(lrc_string):
sub.shift(milliseconds=-1100)
from pylrc.
Hm, where should this be executed? In the terminal? Because I'm not sure where to call toSRT() after this.
from pylrc.
I'd like to have a def shift(self, minutes=0, seconds=0, milliseconds=0)
inside class Lyrics(list)
which then iterates over its lines, if possible. Not sure if your for loop could be used there.
from pylrc.
Do you can program? It seems that you aren't familiar with the basics...
lyrics = pylrc.parse(lrc_string)
for sub in lyrics:
sub.shift(milliseconds=-1100)
lyrics.toSRT()
from pylrc.
Yeah, just not too familiar with Python yet. Thanks.
from pylrc.
Just wondering if you've tried this yourself. I get a list index out of range when converting to SRT
>>> lyrics.toSRT()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/d/tools/python/pylrc/classes.py", line 82, in toSRT
if not self[-1].text.rstrip() == "":
IndexError: list index out of range
As this was in the original code I didn't question the negative index, but is this the issue or is my lrc somehow the problem?
from pylrc.
No, I didn't tried it. I didn't used the srt functionality of this lib. Can you provide the lrc so I can find the problem? Maybe it's a bug in this lib
from pylrc.
Sure. https://pastebin.com/jbqyGQqE I doubt it's the [id:...] thing because that's ignored in the parser, right?
from pylrc.
>>> lrc_file = open('/d/Music/Lyrics/Lovelyz - WoW!.srt')
>>> lrc_string = ''.join(lrc_file.readlines())
>>> lrc_file.close()
>>> lyrics = pylrc.parse(lrc_string)
>>> for sub in lyrics:
... sub.shift(milliseconds=-1100)
...
>>> srt = lyrics.toSRT()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/d/tools/python/pylrc/classes.py", line 82, in toSRT
if not self[-1].text.rstrip() == "":
IndexError: list index out of range
>>>
Am I doing something stupid here?
from pylrc.
Oh by the way, the new timestamps have negative millisecond values, and the end timestamps don't line up with the following begin timestamps.
from pylrc.
Maybe use open('/d/Music/Lyrics/Lovelyz - WoW!.srt', "r", encoding="UTF-8")
? Is the file ending really srt? Yeah, the shift method needs an improvement
from pylrc.
Same problem after doing the same steps with your new open(...)
. It's definitely a .srt file, it has "SRT File" at the "Type" column in explorer, just as proof haha.
from pylrc.
Oh wait that's the problem isn't it... I should be using the .lrc file......
from pylrc.
Alright, so that was obviously dumb, but now I have the following issue
>>> lrc_file = open('/d/Music/Music/K-Pop/Lovelyz/[2017.02.26] Lovelyz - R U Ready/Lovelyz - WoW!.lrc')
>>> lrc_string = ''.join(lrc_file.readlines())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Any idea why you didn't have this problem? (Same happens when adding "r", encoding="UTF-8"
)
from pylrc.
Yes, it must be a lrc file. If declaring the encoding results in an error than use your open line
from pylrc.
Problem is both gave the same output, seems like utf-8 is default.
from pylrc.
Than you have to find out the encoding of the file
from pylrc.
Yep, for some reason that was UCS-2 LE BOM, thanks again. Just one more question from a Python noob, how do I save that srt variable to a file?
from pylrc.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylrc.