Coder Social home page Coder Social logo

Comments (4)

LawnGnome avatar LawnGnome commented on July 23, 2024

Did some experimenting. I can turn one of these into a PR if you want.

Basically, GoogleMusicActions._sanitizePath should return either a properly encoded UTF-8 string (which works great for me on Android, but might fail miserably on Windows โ€”ย I don't really know anything about how Python and Windows interact on that front) or the lowest common denominator ASCII string. Both options are below.

UTF-8 version

def _sanitizePath(self, name):
    name = "".join(i for i in name if i not in "\/:*?<>|,;$%\"\'.`")
    if len(name) > 50: name = name[:50]
    return name.decode("utf8", "ignore").encode("utf8").strip()

As I said, this works really nicely on Android (and should be fine on Linux), but I don't know how portable this will be.

ASCII version

def _sanitizePath(self, name):
    name = "".join(i for i in name if i not in "\/:*?<>|,;$%\"\'.`")
    if len(name) > 50: name = name[:50]
    return name.decode("utf8", "ignore").encode("ascii", "backslashreplace").replace("\\x", "_x").replace("\\u", "_u").strip()

This results in ugly file names (for instance, Sigur Rรณs becomes Sigur R_xf3s) but should work everywhere.

from googlemusic-xbmc.

foreverguest avatar foreverguest commented on July 23, 2024

Thank you, I'll add your fix for the next version.

from googlemusic-xbmc.

foreverguest avatar foreverguest commented on July 23, 2024

Please test this version:
https://app.box.com/s/d0h56sddqomwj46f8amipcebjikpf2w5

from googlemusic-xbmc.

foreverguest avatar foreverguest commented on July 23, 2024

closing for inactivity

from googlemusic-xbmc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.