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

The script doesn't work... #8

Closed
Uri0533 opened this issue Aug 11, 2023 · 9 comments
Closed

The script doesn't work... #8

Uri0533 opened this issue Aug 11, 2023 · 9 comments
Assignees
Labels
question Further information is requested

Comments

@Uri0533
Copy link

Uri0533 commented Aug 11, 2023

I found your script and I really liked the idea. But I tried to run it and I get stuck all the time!
At first I got the following error:
File "C:\FFOutput\Chapterize-Audiobooks-0.6.0\chapterize_ab.py", line 316, in parse_args
args.audiobook.with_suffix('.cue').exists()
AttributeError: 'NoneType' object has no attribute 'with_suffix'

So I went to line 316 and deleted the
or args.audiobook.with_suffix('.cue').exists()
Now the script started working. And I got the message:
ERROR: The script only works with .mp3 files (for now)

I tried different lines and got the same error:

  • chapterize_ab.py -h
  • chapterize_ab.py 'C:\FFOutput\a.mp3' --title 'aaa' --genre 'Fantasy'

I tried at first from the Windows command line, and then also from IDLE (3.11), but without success.
I tried to run older versions of your script, and I got the first error in version 0.5 as well, and the second error in all your versions...
Would appreciate help.
post Scriptum. I don't understand Python that much, so it is not unreasonable that I skipped a step that is obvious to you, simply due to lack of knowledge.

@patrickenfuego
Copy link
Owner

patrickenfuego commented Aug 11, 2023

Hey there! Thanks for your interest. I'm away at the moment but I'll take a look as soon as I get back. I know it's working so there may be a small little step that's missing.

The line you deleted creates a cue file path object based on the input mp3 file's path. Are you passing the absolute path to the mp3 file by chance? If you could, send me your entire command line input and I'll look it over!

@patrickenfuego patrickenfuego self-assigned this Aug 11, 2023
@patrickenfuego patrickenfuego added the bug Something isn't working label Aug 11, 2023
@patrickenfuego
Copy link
Owner

patrickenfuego commented Aug 11, 2023

Looking at it again, there may indeed be a bug. The validation function should covert it to the proper type before it hits that block of code, but it appears to be empty when you hit that portion. I'll look at it right now.

Out of curiosity, did you use the write_cue argument at the command line? I didn't see it in your example. If not, is it enabled your config file?

@Uri0533
Copy link
Author

Uri0533 commented Aug 12, 2023

Hey! This is the code from Windows command line:

C:\Users\User\Downloads\Chapterize-Audiobooks-main>chapterize_ab.py -h

─────────────────────────────────────────────────── Starting script ────────────────────────────────────────────────────

Preparing chapterfying magic ⚡...

Traceback (most recent call last):
File "C:\Users\User\Downloads\Chapterize-Audiobooks-main\chapterize_ab.py", line 1078, in
main()
File "C:\Users\User\Downloads\Chapterize-Audiobooks-main\chapterize_ab.py", line 970, in main
audiobook_file, in_metadata, lang, model_name, model_type, cue_file = parse_args()
^^^^^^^^^^^^
File "C:\Users\User\Downloads\Chapterize-Audiobooks-main\chapterize_ab.py", line 316, in parse_args
args.audiobook.with_suffix('.cue').exists()
^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'with_suffix'

I didn't use the write_cue argument, and its disabled in my config file. when I enable it, the error message change to:
File "C:\Users\User\Downloads\Chapterize-Audiobooks-main\chapterize_ab.py", line 319, in parse_args
cue_file = args.audiobook.with_suffix('.cue')

thanks for your help!

@patrickenfuego
Copy link
Owner

I did some testing and I was unable to reproduce the error you are receiving. I have a questions about your configuration that might help solve the problem.

  1. What version of python are you running?
  2. Are the required packages installed on your system? If so, where are they saved? You can execute pip list -v from the CLI to view all of your installed packages and where they are saved.
  3. Are you're using virtual environments (venv)? If so, make sure the packages are installed inside there or are reachable outside of the venv. Also make sure your venv is active (if you are using one).

Generally you'd prefix python before the script from the CLI. There are exceptions to when this is necessary (such as inside a venv, see above). I'd try adding the python prefix before the script path and see if that helps.

@Uri0533
Copy link
Author

Uri0533 commented Aug 15, 2023

  1. I'm running Python 3.11, on Windows 10. I tried to install Python on another computer and follow the same steps and got the same error.
  2. I installed all the packages listed in requirements.txt. However, it seems to me that the most logical explanation is that I am missing another package that is installed on your computer. Something basic that only I lack.
    I am attaching the list of packages that are installed on my laptop: https://drive.google.com/file/d/1qraUBetRzvMPYzCqar1O7sPRGuXnAGwL/view?usp=sharing
  3. I don't use virtual environments (actually I'm not sure I understand what that means).
  4. I added the prefix py. For some reason if I write python it doesn't work.

thanks again!

@patrickenfuego
Copy link
Owner

patrickenfuego commented Aug 27, 2023

Sorry, things got a bit busy on my end! This is very strange indeed. Installing all of the packages from requirements.txt should do the trick. Let me download the current version and run it myself - I've made a lot of changes in preparation for a new release coming soon and perhaps I inadvertently fixed something I didn't realize was broken.

Just to clarify though, you're running it like so:

PS > python .\chapterize_ab.py -h

That's pretty much the lock stock way of running python scripts on Windows. Unless you've set some kind of alias, prefixing with py shouldn't do anything.

As another follow up, where are your python packages installed? Another thing that might be causing issues is the namespace. Most of the time this isn't an issue, but python provides an environment variable called PYTHONPATH that is meant to fix these types of issues. Try running this as well:

PS > $env:PYTHONPATH = "C:\Users\<user>\Downloads\Chapterize-Audiobooks\"

That will ensure python is properly considering the project directory as a search path.

Lastly, ensure your Python distribution is added to the system PATH. Depending on how you installed python, it should be something like C:\Users\<user>\python3.x\ and C:\Users\<user>\python3.x\Scripts. I believe you have to check a box during installation for it to add these automatically, but I can't remember at the moment. If prefixing python before the script doesn't work, then this is likely the problem.

I'll report back my findings here shortly and let you know if I'm seeing any issues with the current code in main. We'll get you sorted one way or another.

@Uri0533
Copy link
Author

Uri0533 commented Sep 3, 2023

I'm sorry for the delay too. The second thing you said works! I typed "$env:PYTHONPATH = "C:\Users<user>\Downloads\Chapterize-Audiobooks"" in Windows PowerShell and the script started running. Waiting to see the results, It seems to be taking a while...

@Uri0533
Copy link
Author

Uri0533 commented Sep 3, 2023

Thanks a lot!

@patrickenfuego
Copy link
Owner

No worries! That has bitten me in the past, too, unfortunately ☹️ If you want to make it permanent, open up your environment variables menu (type environment variables into windows search and select the first option) then create a new environment variable called PYTHONPATH and set it to the directory of the script. You can always add more paths later if you need.

Anyways, glad to hear it is working. I'm going to close this for now, feel free to reach out again if you run into troubles. I have many new updates coming that address some weird audiobook chapter formats, so stay tuned (just need the time to complete testing).

@patrickenfuego patrickenfuego added question Further information is requested and removed bug Something isn't working labels Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants