abhimanyuPathania / lyrico

A python based command-line lyrics downloader
https://pypi.python.org/pypi/lyrico
Other
15 stars 6 forks source link

Change output of save_to_file? #1

Closed sciuttam closed 8 years ago

sciuttam commented 8 years ago

Hey!

I was looking at the source code and attempted to change how the file was output but when I compile any changes I make to the code are undone.

I'm trying to export the file as [track] [title] so Plex can properly read the lyric files that are generated.

Any help would be greatly appreciated.

Thanks! Anthony

E: This may be slightly more difficult, but passing the existing song file name (sans extension) and exporting the lyrics as that would solve the issue entirely for me.

abhimanyuPathania commented 8 years ago

I sort of understand what you're trying to do. So if you have a song named 02 Help is On the Way.mp3, you would like the lyrics file to be named as 02 Help is On the Way.txt?

I made the the changes and built separate source distribution, which is attached to my reply. You can download the zip and install lyrico locally using python setup.py install. Preferably on a separate virtual environment.

This has the same version as current(0.5.1). But every-time I update lyrico you will have to redo the changes in your version manually(I don't know any other way around this).

Now coming to changing source code of your installation; I don't understand what you mean by: "attempted to change how the file was output but when I compile any changes I make to the code are undone.". If you want to change local source, you've to make changes where the files are installed. So if you pip installed directly, you will have to make change to the package files in your python directory; for example C:\Python27\Lib\site-packages\lyrico.

If you're using a separate virtual environment, you've to go to that venv's folder and make changes there. I tried it and it was working.

For your reference the only changes you need to make are in song_helper.py file's get_song_data function. I added line 183-187(to extract song file-name) and added line 223(commenting out old) updating lyrics_file_name variable to use song file-name instead. You can use this to redo change if I release any updated version. lyrico-0.5.1.zip

sciuttam commented 8 years ago

Awesome, thanks! That was super quick :)

By compile problem, I meant once I ran the pip install command. I removed my installation of lyrico, modified the song_helper.py but when I ran pip install it didn't take any of the changes I made. Do I need to recompile and then run pip install?

Python is a language I have never worked with, so I may be using incorrect terminology. I'm primarily a C++/VB person.

Thanks for the help! Anthony Sciutto

abhimanyuPathania commented 8 years ago

"modified the song_helper.py" - modified where?

Because when you run the command pip install lyrico, it downloads the package from PyPI and installs it and not from your local hard drive. You can think of PyPI as cloud where all the python packages live. So your editing the package locally won't make a difference if you run pip install lyrico.

But you can use pip to install packages from local system as well. The command looks similar: pip install path/to/your/package So to install the package I attached in previous comment with pip instead of python setup.py install, the command would look like this: pip install path/to/lyrico-0.5.1.zip

So If you make changes to zip then probably they would be reflected. What I was referring to was to make changes to source after you install your package. Because pip install just creates a directory with name package(here lyrico), which contains all the files as you see in the git repo which then can be edited. But you need to know where they are.

sciuttam commented 8 years ago

Further clarification of my ignorance! I had no idea pip install by default did not use the locally downloaded files.

I modified my local copy of song_helper.py after unzipping it, but before running pip install.

So if I understand you correctly, I have to point pip to the modified zip for any local changes to be reflected?

abhimanyuPathania commented 8 years ago

It should. But the correct way would be to simply edit the files(ones that go into your python dir) after you install the normal version.

Can you tell me how did you come across this python package?

sciuttam commented 8 years ago

I found the package by Googling for a lyric package and it took me to the PyPi website.

https://pypi.python.org/pypi/lyrico/0.5.1

Initially it took me to version 0.3.0, but it had a link to the latest version.