After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 673565 - [playbin2] File URI containing % is not played
[playbin2] File URI containing % is not played
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gst-python
0.10.x
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-04-05 12:19 UTC by hjuvi
Modified: 2012-04-06 11:28 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description hjuvi 2012-04-05 12:19:47 UTC
It is not possible to play a file containing % character...

self.player = gst.element_factory_make('playbin2', 'player')
fakesink = gst.element_factory_make('fakesink', 'fakesink')
self.player.set_property('video-sink', fakesink)
self.player.set_property('uri', 'file:///home/xxx/100%.flac')
self.player.set_state(gst.STATE_PLAYING)

Player does not start.

I've filed the bug under "gst-python" category, although I'm not quite sure it is related to python bindings... but:
- in my own code, written in python, I can't play this file.
- decibel-audio-player, written in python, can't play this file.
- banshee, written in C#, can play this file.
Comment 1 Sebastian Dröge (slomo) 2012-04-06 07:03:55 UTC
That's probably because Python handles the % character in a special way (it's used as a placeholder for formatting strings). URIs also are not allowed to contain %, you have to escape that too.

Use whatever Python provides to escape URIs or generate URIs from filenames. GLib has g_filename_to_uri() for this for example.
Comment 2 hjuvi 2012-04-06 11:28:04 UTC
Thank you.
I've tried this and it works fine:

from urllib import pathname2url
self.player.set_property('uri', 'file://' + pathname2url(filename))

I don't know if this is the better way to do it (URL vs URI), but it seems that g_filename_to_uri has no python binding...