After Pi Uploaded music does not work.

Issue #7 resolved
Jonathan Woodell created an issue

I am having a problem playing music that has been uploaded with the web-gui after a pi restart. I have looked around but can not find the cause.

How to recreate

-Upload Song

-Restart Pi with the button in GUI

-Song will not play after restart.

Comments (17)

  1. tom enos

    @stephen_burning If you review the link I gave you to review it has a work around for this issue in the Upload classes post method.
    f_name = ''.join(os.path.basename(x.filename).split())
    This just removes the spaces.

  2. Stephen Burning repo owner

    i think the real question is why does file names with spaces break things. People should be able to have file names with spaces. I haven't looked at this piece of the code in a while, will have to refresh myself.

  3. Stephen Burning repo owner

    I just looked at my songs and they all have spaces in them, but all work with out changing the code. Is there maybe something else going on?.songlist.png

  4. tom enos

    I upload 3 songs from my wife's window 7 laptop that had spaces in the names and none of them would play used (Chrome browser).
    I changed the file names and uploaded them again and they played.

  5. Stephen Burning repo owner

    Oh OK that's the difference. I transfered them with ftp. So escaping the name on the web upload should fix it.

  6. tom enos

    If you escape the character there you will see the backslah in the song list. Escape the file name in synchronized lights, in the play function
    song_filename = song_filename.replace(" ", "\ ")

  7. tom enos

    found the problem What are valid values for the id attribute in HTML? For HTML 4, the answer is technically:

    ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). HTML 5 is even more permissive, saying only that an id must contain at least one character and may not contain any space characters.

  8. tom enos

    A hack, in maintest.js getSongs()
    temp2=data.songs[i][1].split(' ').join('---')
    temp+="<li data-theme='d'><a class='song' href='#' id="+temp2+">"+data.songs[i][0]+"</a></li>";

    And code.py Ajax/POST() we undo it

            elif varariables.option == '1':
                slc.play_single(varariables.song.replace("---", " "))
    

    of course that is just for playing a single song and it looks hackish at best

  9. Stephen Burning repo owner

    I found a much easier solution. just had to update maintest.js on line 63 to have a single quote before and after the id. This was already correct on line 160, but i must have missed it on line 63.

  10. Log in to comment