1

Sorry if this is an easy one, but I'm learning and I'm new to python. I have a textbox where you can input some text but I need to remove special characters as it seems to be gumming up some other operations. I've tried different ways of using .replace('"', '') but I'm just getting errors.

here's my code that grabs the textbox input

def setter(self):
        self.url = self.url.get()
        self.artist = self.artist.get()
        self.album = self.album.get()
        self.album_artist = self.album_artist.get()
        self.genre = self.genre.get()
        self.year = self.year.get()
        self.textBox = self.textBox.get("1.0", END)
        if self.artist or self.album or self.year:
            self.folder_name = self.artist + " - " + self.album + " (" + self.year + ")"

The error

"Michael P. Shipley's" ETERNAL Mistake is processing.
Exception in Tkinter callback
Traceback (most recent call last):
  File "tkinter\__init__.py", line 1883, in __call__
  File "AlbumWindow.py", line 64, in <lambda>
  File "AlbumWindow.py", line 93, in setEntries
  File "AlbumWindow.py", line 203, in instructions
  File "AlbumWindow.py", line 182, in trackSplitter
  File "site-packages\pydub\audio_segment.py", line 780, in export
  File "site-packages\pydub\utils.py", line 57, in _fd_or_path_or_tempfile
OSError: [Errno 22] Invalid argument: 'mick gordon - doom ost (2020)/"Michael P. Shipley\'s" ETERNAL Mistake.mp3'

Anything with quotes and some japanese characters are making it fail, I need to basically remove all special characters from self.textBox except for :

If I manually remove the " out of the textBox before I submit everything works fine.

Thanks!

stovfl
  • 14,998
  • 7
  • 24
  • 51
  • you could [translate](https://www.tutorialspoint.com/python-maketrans-and-translate-functions) the special characters away, also which errors are you getting? – Nullman Mar 26 '20 at 11:57
  • some japanese characters and quotes are causing the problems, i updated the question with the full error code – FragThePlanet Mar 26 '20 at 12:11
  • `'mick gordon - doom ost (2020)/"Michael P. Shipley\'s" ETERNAL Mistake.mp3'`,There are some sensitive character in your path.Your file name shouldn't include `? * : " < > \ / |`. – jizhihaoSAMA Mar 26 '20 at 12:24
  • I know thats what I'm trying to remove out, If i delete the quotes manually when I enter into the textBox everything works fine – FragThePlanet Mar 26 '20 at 12:26
  • that looks like it's pointing me in the right direction, I'll check it out thanks – FragThePlanet Mar 26 '20 at 12:37

0 Answers0