Git Product home page Git Product logo

Comments (22)

SimonIT avatar SimonIT commented on July 1, 2024 1

Yes, the id gets ignored. I don't got any problem. This is my result: https://pastebin.com/KKuXYWYx

from pylrc.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024 1

Nvm,

>>> f = open('/d/Downloads/Lovelyz - WoW! 3.srt', 'w')
>>> f.write(srt)
4286
>>> f.close()

worked.

from pylrc.

SimonIT avatar SimonIT commented on July 1, 2024

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.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

Thanks for the quick response, how does one iterate over the Lyrics object?

from pylrc.

SimonIT avatar SimonIT commented on July 1, 2024

For example like this:

for sub in pylrc.parse(lrc_string):
    sub.shift(milliseconds=-1100)

from pylrc.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

Hm, where should this be executed? In the terminal? Because I'm not sure where to call toSRT() after this.

from pylrc.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

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.

SimonIT avatar SimonIT commented on July 1, 2024

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.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

Yeah, just not too familiar with Python yet. Thanks.

from pylrc.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

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.

SimonIT avatar SimonIT commented on July 1, 2024

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.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

Sure. https://pastebin.com/jbqyGQqE I doubt it's the [id:...] thing because that's ignored in the parser, right?

from pylrc.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024
>>> 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.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

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.

SimonIT avatar SimonIT commented on July 1, 2024

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.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

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.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

Oh wait that's the problem isn't it... I should be using the .lrc file......

from pylrc.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

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.

SimonIT avatar SimonIT commented on July 1, 2024

Yes, it must be a lrc file. If declaring the encoding results in an error than use your open line

from pylrc.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

Problem is both gave the same output, seems like utf-8 is default.

from pylrc.

SimonIT avatar SimonIT commented on July 1, 2024

Than you have to find out the encoding of the file

from pylrc.

PlaylistsTrance avatar PlaylistsTrance commented on July 1, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.