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

save as txt instead of json #277

Open
ClaireCJS opened this issue Oct 28, 2024 · 6 comments
Open

save as txt instead of json #277

ClaireCJS opened this issue Oct 28, 2024 · 6 comments
Labels
feature request Requesting a feature good first issue Good issue for a first-time contributor to tackle
Milestone

Comments

@ClaireCJS
Copy link

Instead of json

I just want a TXT of the lyrics

@allerter
Copy link
Contributor

If you're using the command line tool, currently there's no way to save lyrics as TXT. Otherwise, when calling for example Artist.save_lyrics() you can change the format of the file using the extension parameter.

@kqvanity
Copy link

kqvanity commented Dec 8, 2024

@allerter How about redirecting to stdout instead of writing to disk?

@ClaireCJS
Copy link
Author

ClaireCJS commented Dec 8, 2024

I'm using this as part of a system. So I'm not invoking it manually.

And I’ve had problems with needing a TXT file, as well as with being able to manipulate the results.

Here’s how I got around it.

I wrote a json-to-txt postprocessor explicitly for the output generated by LyricsGenius.exe

Since the output filename is variable, and may or may not exist, it’s kind of hard to look at the file to know if it exists and is valid. [However, the variable output filename is VERY useful as a sanity check for whether the correct lyrics were found, so I quite liked it in the end.]

So I have to actually have to:

  1. create a temp file (“__”)
  2. run the LyricsGenius.exe downloader
  3. check what the latest file in the folder is (i have a set-latest-filename.bat I use)
  4. if the latest file is my “__” file, consider the downloader unsuccessful
  5. if the latest file is NOT my “__” file, store the latest file’s filename. That’s our download. We’ll need to use it later.
  6. Check if that download is 0 bytes or not
  7. If it’s ≤0 bytes, delete it and consider it unsuccessful (i have a TCC-specific delete-zero-byte-files.bat one could modify)
  8. If it’s >0 bytes, consider it successful

It’s a bit cumbersome. If there was simply an option to specify the output file, it would have saved me all that.

Caveat: The option may be there and maybe I simply missed it and wasted my own time 😂

@allerter
Copy link
Contributor

allerter commented Dec 8, 2024

@kqvanity, sadly no. The CLI is pretty simple and can only save as JSON. For anything more, you'd need to use Python.

@allerter allerter added good first issue Good issue for a first-time contributor to tackle feature request Requesting a feature labels Dec 8, 2024
@allerter allerter added this to the 4.0.0 milestone Dec 8, 2024
@kqvanity
Copy link

kqvanity commented Dec 9, 2024

@allerter
I'm for json as well. I just want it to pipe its output to jq right away, instead of it writing & reading from a file. If one want to save file then > filex.json

@allerter
Copy link
Contributor

@kqvanity, simply not possible with the current state of the CLI. If you have more questions regarding the CLI, feel free to open another issue. I'll lock this for now

Repository owner locked as resolved and limited conversation to collaborators Dec 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request Requesting a feature good first issue Good issue for a first-time contributor to tackle
Projects
None yet
Development

No branches or pull requests

3 participants