HELP: Download file using the userid inputed from settings.xml
#1
HI,
I have a quick question... It's going to be something really basic but I can't find it..


Basically,
When my add-on is started, it downloads data files (.xml) from my server..

I have added .xml files for every user eg:
welcome-aarronlee.xml (aarronlee is the username of a forum I have).

I would like to put such command like "welcome-$user.xml" so the username in settings.xml changes "$username" to the username inputed in the config del addon...


At the moment I have it set to "welcome.xml" so that anyone can access it, but I would like to make it more specific for added security so that only the files (of each user) I have uploaded to my server would load without manually having to do an add-on customized for every user as there are about 60 people with this add-on.

I also don't want the add-on connecting to auth the user... just make it "do-able" and keeping it basic making the user input his username in the username textbox of the configuration of the add-on and have python recognise this and add the username id to the .xml

Here is an example of coding:

addon.py:
Code:
import StringIO
import os
import threading
import datetime
import time
import urllib2
import urllib
from xml.etree import ElementTree
import buggalo
import xbmcaddon
import xbmcplugin
from strings import *
import xbmc
import xbmcgui
import xbmcvfs
import sqlite3

def parseCATEGORIES(self, f, context):
    import os
    path = os.path.join(datapath, 'welcome.xml')  *** THIS IS WHAT I NEED TO CHANGE
    if os.path.exists(path):
        f = open(path)
        xml = f.read()
        f.close()



    for event, elem in context:
        if event == "end":
            result = None
            if elem.get == "channel":
                categories = elem.findtext("category")
                result = Channel(categories)
            return self.categories
        else:
            return None

settings.xml:
Code:
    <category label="Username Data">
    <setting id="user" type="text" label="username" default=""/> *** THIS IS WHERE THE USER WOULD INPUT HIS DETAILS
        
        <setting id="notifications.enabled" label="30106" type="bool" default="false" visible="false"/>
        <setting id="dummy" label="30108" type="action" action="RunScript($CWD/notification.py)" visible="false"/>

</category>



I hope I have explained correctly...


Thanks
Reply
#2
You can use GetSettings to get the user name from the settings.xml file and then use that variable in the path.join statement.

Should be pretty easy to do.

Hopefully that is what you were looking for.
Reply
#3
I'm quite new to this....
How do I do that? I don't know where to start
Reply

Logout Mark Read Team Forum Stats Members Help
HELP: Download file using the userid inputed from settings.xml1