ebb-earl-co / tidal-wave

Waving at the TIDAL music service
Apache License 2.0
35 stars 2 forks source link

Special characters in filenames #99

Closed it-does-compute closed 4 months ago

it-does-compute commented 4 months ago

The windows filesystem does not support certain characters like quotes. If songs contain these characters then the program stops and throws error OSError[Errno 22]. In some instances the quotes are removed but other times they are not.

Here's one song example which causes this error https://tidal.com/track/233202975?u

ebb-earl-co commented 4 months ago

@it-does-compute thank you for having raised this issue. There have been a few similar issues raised in the past, and I thought that I had squashed the problems, but the error in this case comes from the version of the track, not the track name itself. To wit,

@dataclass
class TracksEndpointResponseJSON(dataclass_wizard.JSONWizard):
    """Response from the TIDAL API, tracks/{TRACKID} endpoint. If the params and
    headers are correctly specified, the API returns metadata of the available
    version of the audio track, including audio quality, track title, ISRC,
    track artists, album, track number, duration, etc."""

    id: int = field(repr=False)
    title: str
    duration: int  # seconds
    replay_gain: float = field(repr=False)
    peak: float = field(repr=False)
    track_number: int
    volume_number: int
    version: Optional[str]
    copyright: str = field(repr=False)
    url: str
    isrc: str = field(repr=False)
    explicit: bool
    audio_quality: str = field(repr=False)
    audio_modes: List[str] = field(repr=False)
    media_metadata: "MediaMetadata"
    artist: "Artist"
    artists: List["Artist"]
    album: "TrackAlbum"

    def __post_init__(self):
        name: str = replace_illegal_characters(self.title)
        version: str = replace_illegal_characters(self.version)  <---- Added this bit
        self.name: str = name if self.version is None else f"{name} ({version})"

Until I create a new version, wait an hour or so, and then you can install this change with

PS > python.exe -m pip install https://github.com/ebb-earl-co/tidal-wave/archive/trunk.zip