Kodi Community Forum

Full Version: Python3 url with vaules print me + instead of %20 (space)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi i try to make a little plugin to get stalker portals working

it reads the streamadress from a file (cachefile)
as example 
"cmd":"ffmpeg http://localhost/ch/162691_

the code is this

def retrive_defaultUrl(url, channel, tmp):

    if tmp == '0':
        s = channel.split('');
        url = s[0];
        if len(s)>1:
            url = s[1];
        return url;


    handshake(url);
    
    cmd = channel;

    

    info = retrieveData(url, values = {
        'type' : 'itv', 
        'action' : 'create_link', 
        'cmd' : channel});
    cmd = info['js']['cmd'];
        
    s = cmd.split(' ');
            
    url = s[0];
    
    if len(s)>1:
        url = s[1];

the result is :
type=itv&action=create_link&cmd=ffmpeg+http%3A%2F%2Flocalhost%2Fch%2F162691_

but this + sign between ffmpeg and http should be %20 for space

so how i can change the + to %20
it also create the link to play the stream

http://s1.nasaservers.com:8080/SKLcYWDZw...OCtIGjHqsg

so all works correct only the + sing is the problem

error i got
"list index out of range"
Use urllib quote to translate the path:
https://docs.python.org/3/library/urllib...arse.quote

py3
from urllib.parse import quote

url = quote(your_url)