def registerDonor(f=None):
    """Register a donor"""
    name = getInput(str, "Enter donor name: ")
    pc = int(getInput(isPositive, "Enter postcode: "))
    btype = getInput(isBloodType, "Enter blood type: ")

    d = Donor(name, pc, btype)
    d.verify(btype)
Exemplo n.º 2
0
def mount_Donor( line ):
    '''
    Mounts and returns a Donor object from a [line] (string) that meets Donor.encode() sintaxe.
    Note: No verification is run on this procedure.
    '''
    field = disassemble(line)
    #==========< "decode" of field >=========#
    number = field[0]
    name = field[1]
    SNS = field[2]
    ABO = field[3]
    Rh = field[4]
    gender = field[5]
    birthdate = datetime.strptime( field[6], '%d-%m-%Y').date()
    #==< contacts >==# (optional fields)
    street = field[7] if field[7] != 'None' else None
    postcode = field[8] if field[8] != 'None' else None
    city = field[9] if field[9] != 'None' else None
    country = field[10] if field[10] != 'None' else None
    email = field[11] if field[11] != 'None' else None
    phone = field[12] if field[12] != 'None' else None
    mobile = field[13] if field[13] != 'None' else None
    #=========< Assembly of Donor >=========#
    donor = Donor( Donor_num( number ), Name( name ), SNS_num( SNS ), Bloodtype( ABO, Rh ), Gender( gender ), Birthdate( birthdate ),\
                   Contacts( Address( street, postcode, city, country), Email( email ), Phone( phone ), Mobile( mobile )))
    return donor
Exemplo n.º 3
0
def menu_choose(choosen):
    if choosen=='1':
        os.system('cls')
        print("New Donor")
        Donor.donor_main()
        print('1. New add donor')
        print('2. Back')
        add_end('donor')
    elif choosen=='2':
        os.system('cls')
        print("New Donation event")
        donation_location.main()
        print('1. New add donation event')
        print('2. Back')
        add_end('donation')
    elif choosen=='3':
        os.system('cls')
        print("Delete Donor")
        delete_donation.delete_donor_from_csv_file()
    elif choosen=='4':
        os.system('cls')
        print("Delete Donation event")
        delete_donation.delete_donations_from_csv_file()
    elif choosen=='5':
        os.system('cls')
        print("List Donors or Donation events")
        print("\t1. Donors")
        print("\t2. Donation events")
        print("Choose one!")
        get=msvcrt.getwch()
        if get=="1":
            listing.list_donors()
        elif get=="2":
            listing.list_donations()
        else:
            menu_choose('5')
    elif choosen=='6':
        search_menu()
    elif choosen=='7':
        modify.donor_data_modifier()
    elif choosen=='8':
        Donation_change.donation_data_modifier()
    elif choosen=='9':
        os.system('exit')
    else:
        print("You must choose one!")
Exemplo n.º 4
0
def menu_choose(choosen):
    if choosen == '1':
        os.system('cls')
        print("New Donor")
        Donor.donor_main()
        print('1. New add donor')
        print('2. Back')
        add_end('donor')
    elif choosen == '2':
        os.system('cls')
        print("New Donation event")
        donation_location.main()
        print('1. New add donation event')
        print('2. Back')
        add_end('donation')
    elif choosen == '3':
        os.system('cls')
        print("Delete Donor")
        delete_donation.delete_donor_from_csv_file()
    elif choosen == '4':
        os.system('cls')
        print("Delete Donation event")
        delete_donation.delete_donations_from_csv_file()
    elif choosen == '5':
        os.system('cls')
        print("List Donors or Donation events")
        print("\t1. Donors")
        print("\t2. Donation events")
        print("Choose one!")
        get = msvcrt.getwch()
        if get == "1":
            listing.list_donors()
        elif get == "2":
            listing.list_donations()
        else:
            menu_choose('5')
    elif choosen == '6':
        search_menu()
    elif choosen == '7':
        modify.donor_data_modifier()
    elif choosen == '8':
        Donation_change.donation_data_modifier()
    elif choosen == '9':
        os.system('exit')
    else:
        print("You must choose one!")
Exemplo n.º 5
0
 def add_blood(self, donor_name: str, donor_id: str, source: str, blood_type="", use_by=-1) -> int:
     donor = Donor(donor_name, donor_id)
     blood = Blood(len(self._bloods), donor)
     if source == 'Bat-Mobile':
         blood.test_state = BloodTestState.NOT_TESTED
         donor.history.append(blood)
         
     elif source == 'Red Cross':
         blood.test_state = BloodTestState.GOOD
         blood.use_by = use_by
         blood.type = blood_type
         
     else:
         raise ValueError(f"invalid source: {source}")
     self._bloods.append(blood)
     self._lc.check_level()
     return len(self._bloods) - 1
Exemplo n.º 6
0
 def create_donor (self, name, sns_num, bloodtype, gender, birthdate, contacts):
     '''
     Returns an instance of Donor class with an previously unassigned donor number.
     Assumes that all arguments are valid (validated during input procedure).
     Generates a valid unassigned donor number.
     Note: Assumes that all donor numbers have 6 digits.
     '''
     #Warning:
     # We are aware that this method of generating donor's numbers imply that:
     #  1) The available numbers will eventually run out and the program will enter an infinite loop;
     #  2) Number generation will get slower as numbers available decrease.
     #  For the purpose of this exercise we considered those limitations acceptable.
     #==================<Notes>=====================
     #[name] is an instance of Name class
     #[sns_num] is an instance of SNS_num class
     #[bloodtype] is an instance of Bloodtype class
     #[ABO] is an attribute of Bloodtype class
     #[Rh] is an attribute of Bloodtype class
     #[gender] is an instance of Gender class
     #[birthdate] is an instance of Birthdate class
     #[contacts] is an instance of Contacts class
     #[address] is an instance of Address class
     #[street] is an attribute of Address class
     #[postcode] is an attribute of Address class
     #[city] is an attribute of Address class
     #[country] is an attribute of Address class
     #[email] is an instance of Email class
     #[phone] is an instance of Phone class
     #[mobile] is an instance of Mobile class
     #==============================================
     while True:
         intNumber = randint(1, 999999) #at most 6 digits
         strNumber = str( intNumber )
         rawNumber = strNumber.zfill(6) #assures 6 digits by filling the remainder with zeros to the left
         if rawNumber not in self.donor_Map:
             donorNumber = Donor_num(rawNumber) #[donorNumber] is an instance of Donor_num class
             break
     return Donor(donorNumber, name, sns_num, bloodtype, gender, birthdate, contacts)
Exemplo n.º 7
0
class Migrate:

    def log(self, msg, level = xbmc.LOGDEBUG):
        Globals.log('Migrate: ' + msg, level)

    def logDebug(self, msg, level = xbmc.LOGDEBUG):
        if Globals.REAL_SETTINGS.getSetting('enable_Debug') == "true":
            Globals.log('Migrate: ' + msg, level)
            
    def migrate(self):
        self.log("migrate")
        settingsFile = xbmc.translatePath(os.path.join(Globals.SETTINGS_LOC, 'settings2.xml'))    
        chanlist = ChannelList.ChannelList()
        chanlist.background = True
        chanlist.forceReset = True
        chanlist.createlist = True
        
        # If Autotune is enabled direct to autotuning
        if Globals.REAL_SETTINGS.getSetting("Autotune") == "true" and Globals.REAL_SETTINGS.getSetting("Warning1") == "true":
            self.log("autoTune, migrate")
            if self.autoTune():
                return True
        else:
            if FileAccess.exists(settingsFile):
                return False
            else:
                currentpreset = 0

            for i in range(Globals.TOTAL_FILL_CHANNELS):
                chantype = 9999

                try:
                    chantype = int(Globals.ADDON_SETTINGS.getSetting("Channel_" + str(i + 1) + "_type"))
                except:
                    pass

                if chantype == 9999:
                    self.log("addPreset")
                    self.addPreset(i + 1, currentpreset)
                    currentpreset += 1
                    
        return True

    
    def addPreset(self, channel, presetnum): # Initial settings2.xml preset on first run when empty...
    # Youtube
        BBCWW = ['BBCWW']
        Trailers = ['Trailers']
    # RSS
        HDNAT = ['HDNAT']
        TEKZA = ['TEKZA']
        
        if presetnum < len(BBCWW):
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_type", "10")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_1", "BBCWorldwide")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_2", "1")            
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_3", "50")            
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rulecount", "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rule_1_id", "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rule_1_opt_1", "BBC World News")
        elif presetnum - len(BBCWW) < len(Trailers):
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_type", "10")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_1", "movieclips")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_2", "1")          
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_3", "50")            
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rulecount", "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rule_1_id", "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rule_1_opt_1", "Movie Trailers")
        elif presetnum - len(BBCWW) - len(Trailers) < len(HDNAT):
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_type", "11")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_1", "http://revision3.com/hdnation/feed/Quicktime-High-Definition")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_2", "1")     
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_3", "50")            
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rulecount", "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rule_1_id", "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rule_1_opt_1", "HD Nation")
        elif presetnum - len(BBCWW) - len(Trailers) - len(HDNAT) < len(TEKZA):
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_type", "11")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_1", "http://revision3.com/tekzilla/feed/quicktime-high-definition")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_2", "1")            
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_3", "50")            
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rulecount", "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rule_1_id", "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_rule_1_opt_1", "Tekzilla")
            
              
    def autoTune(self):
        self.log('autoTune, Init')
        curtime = time.time()
        chanlist = ChannelList.ChannelList()
        chanlist.background = True
        # chanlist.needsreset = True
        chanlist.makenewlists = True
        try:
            self.Donor = Donor()
        except:
            pass
        settingsFile = xbmc.translatePath(os.path.join(Globals.SETTINGS_LOC, 'settings2.xml'))
        
        if  FileAccess.exists(settingsFile):
            try:
                os.remove(settingsFile)
            except:
                self.log("autoTune, Unable to delete " + str(settingsFile))

        channelNum = 0
        updateDialogProgress = 0
        
        self.updateDialog = xbmcgui.DialogProgress()
        self.updateDialog.create("PseudoTV Live", "Auto Tune")
        
        # LiveTV - PVR
        self.updateDialogProgress = 5
        if Globals.REAL_SETTINGS.getSetting("autoFindLivePVR") == "true" and Globals.REAL_SETTINGS.getSetting('xmltvLOC') != '':
            self.log("autoTune, Adding Live PVR Channels")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Live PVR Channels","")
            CHnum = 0
            RCHnum = 0
            CHid = 0
            CHlst = ''
            CHname = ''
            CHzapit = ''
            if channelNum == 0:
                channelNum = 1
            try:
                json_query = '{"jsonrpc":"2.0","method":"PVR.GetChannels","params":{"channelgroupid":2}, "id":1}'
                json_folder_detail = chanlist.sendJSON(json_query)
                file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(json_folder_detail)
                self.logDebug('autoFindLivePVR, file_detail = ' + str(file_detail))
                self.xmlTvFile = xbmc.translatePath(os.path.join(Globals.REAL_SETTINGS.getSetting('xmltvLOC'), 'xmltv.xml'))

                f = FileAccess.open(self.xmlTvFile, "rb")
                tree = ET.parse(f)
                root = tree.getroot()

                file_detail = str(file_detail)
                CHnameLST = re.findall('"label" *: *(.*?),', file_detail)
                CHidLST = re.findall('"channelid" *: *(.*?),', file_detail)
                self.logDebug('autoFindLivePVR, CHnameLST = ' + str(CHnameLST))
                self.logDebug('autoFindLivePVR, CHidLST = ' + str(CHidLST))
                    
                for CHnum in range(len(file_detail)):
                    CHname = CHnameLST[CHnum]
                    CHname = str(CHname)
                    CHname = CHname.split('"', 1)[-1]
                    CHname = CHname.split('"')[0]
                    CHlst = (CHname + ',' + CHidLST[CHnum])
                    inSet = False
                    self.logDebug('autoFindLivePVR, CHlst.1 = ' + str(CHlst))
                    # search xmltv for channel name, then find its id
                    for elem in root.getiterator():
                        if elem.tag == ("channel"):
                            name = elem.findall('display-name')
                            for i in name:
                                RCHnum = (CHnum + 1)
                                if CHname == i.text:
                                    CHzapit = elem.attrib
                                    CHzapit = str(CHzapit)
                                    CHzapit = CHzapit.split(": '", 1)[-1]
                                    CHzapit = CHzapit.split("'")[0]
                                    CHlst = (CHlst + ',' + str(CHzapit))
                                    self.logDebug('autoFindLivePVR, CHlst.2 = ' + str(CHlst))
                                    inSet = True
                    
                    self.log('autoFindLivePVR, inSet = ' + str(inSet) + ' , ' +  str(CHlst))
                    if inSet == True:
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "8")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", CHzapit)
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_2", "pvr://channels/tv/All TV channels/" + str(CHnum) + ".pvr")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_3", "xmltv")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_4", "")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rulecount", "1")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_id", "1")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_opt_1", CHname + ' LiveTV')  
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                        channelNum = channelNum + 1
                    
                    if inSet == False:
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "9")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", "5400")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_2", "pvr://channels/tv/All TV channels/" + str(CHnum) + ".pvr")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_3", CHname)
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_4", "XMLTV DATA NOT FOUND")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rulecount", "1")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_id", "1")
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_opt_1", CHname + ' LiveTV')  
                        Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                        channelNum = channelNum + 1  
            except:
                pass
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

            
        # Custom Channels
        self.updateDialogProgress = 15
        if Globals.REAL_SETTINGS.getSetting("autoFindCustom") == "true" :
            self.log("autoTune, Adding Custom Channel")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Custom Channel","")
            i = 1
            for i in range(500):
                if os.path.exists(xbmc.translatePath('special://profile/playlists/video') + '/Channel_' + str(i + 1) + '.xsp'):
                    self.log("autoTune, Adding Custom Video Playlist Channel")
                    channelNum = channelNum + 1
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "0")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", str(xbmc.translatePath('special://profile/playlists/video/') + "Channel_" + str(i + 1) + '.xsp'))
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rulecount", "1")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_id", "1")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_opt_1", Globals.uni(chanlist.cleanString(chanlist.getSmartPlaylistName(xbmc.translatePath('special://profile/playlists/video') + '/Channel_' + str(i + 1) + '.xsp'))))
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(self.updateDialogProgress,"PseudoTV Live","Found " + Globals.uni(chanlist.getSmartPlaylistName(xbmc.translatePath('special://profile/playlists/video') + '/Channel_' + str(i + 1) + '.xsp')),"")
                elif os.path.exists(xbmc.translatePath('special://profile/playlists/mixed') + '/Channel_' + str(i + 1) + '.xsp'):
                    self.log("autoTune, Adding Custom Mixed Playlist Channel")
                    channelNum = channelNum + 1
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "0")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", str(xbmc.translatePath('special://profile/playlists/mixed/') + "Channel_" + str(i + 1) + '.xsp'))
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rulecount", "1")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_id", "1")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_opt_1", Globals.uni(chanlist.cleanString(chanlist.getSmartPlaylistName(xbmc.translatePath('special://profile/playlists/mixed') + '/Channel_' + str(i + 1) + '.xsp'))))
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(self.updateDialogProgress,"PseudoTV Live","Found " + Globals.uni(chanlist.getSmartPlaylistName(xbmc.translatePath('special://profile/playlists/mixed') + '/Channel_' + str(i + 1) + '.xsp')),"")
                elif os.path.exists(xbmc.translatePath('special://profile/playlists/music') + '/Channel_' + str(i + 1) + '.xsp'):
                    self.log("autoTune, Adding Custom Music Playlist Channel")
                    channelNum = channelNum + 1
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "0")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", str(xbmc.translatePath('special://profile/playlists/music/') + "Channel_" + str(i + 1) + '.xsp'))
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rulecount", "1")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_id", "1")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_opt_1", Globals.uni(chanlist.cleanString(chanlist.getSmartPlaylistName(xbmc.translatePath('special://profile/playlists/music') + '/Channel_' + str(i + 1) + '.xsp'))))
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(self.updateDialogProgress,"PseudoTV Live","Found " + Globals.uni(chanlist.getSmartPlaylistName(xbmc.translatePath('special://profile/playlists/music') + '/Channel_' + str(i + 1) + '.xsp')),"")
        
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))
        
        #TV - Networks/Genres
        self.updateDialogProgress = 20
        self.log("autoTune, autoFindNetworks " + str(Globals.REAL_SETTINGS.getSetting("autoFindNetworks")))
        self.log("autoTune, autoFindTVGenres " + str(Globals.REAL_SETTINGS.getSetting("autoFindTVGenres")))
        if (Globals.REAL_SETTINGS.getSetting("autoFindNetworks") == "true" or Globals.REAL_SETTINGS.getSetting("autoFindTVGenres") == "true"):
            self.log("autoTune, Searching for TV Channels")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Searching for TV Channels","")
            chanlist.fillTVInfo()

        # need to add check for auto find network channels
        self.updateDialogProgress = 21
        if Globals.REAL_SETTINGS.getSetting("autoFindNetworks") == "true":
            self.log("autoTune, Adding TV Networks")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding TV Networks","")
            i = 1
            for i in range(len(chanlist.networkList)):
                channelNum = channelNum + 1
                # add network presets
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1",Globals.uni(chanlist.networkList[i]))
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding TV Network",Globals.uni(chanlist.networkList[i]))
        
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))
        
        self.updateDialogProgress = 22
        if Globals.REAL_SETTINGS.getSetting("autoFindTVGenres") == "true":
            self.log("autoTune, Adding TV Genres")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding TV Genres","")
            channelNum = channelNum - 1
            for i in range(len(chanlist.showGenreList)):
                channelNum = channelNum + 1
                # add network presets
                if chanlist.showGenreList[i] != '':
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "3")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", Globals.uni(chanlist.showGenreList[i]))
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding TV Genres",Globals.uni(chanlist.showGenreList[i]) + " TV")
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))
        
        self.updateDialogProgress = 23
        self.log("autoTune, autoFindStudios " + str(Globals.REAL_SETTINGS.getSetting("autoFindStudios")))
        self.log("autoTune, autoFindMovieGenres " + str(Globals.REAL_SETTINGS.getSetting("autoFindMovieGenres")))
        if (Globals.REAL_SETTINGS.getSetting("autoFindStudios") == "true" or Globals.REAL_SETTINGS.getSetting("autoFindMovieGenres") == "true"):
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Searching for Movie Channels","")
            chanlist.fillMovieInfo()

        self.updateDialogProgress = 24
        if Globals.REAL_SETTINGS.getSetting("autoFindStudios") == "true":
            self.log("autoTune, Adding Movie Studios")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Movie Studios","")
            i = 1
            for i in range(len(chanlist.studioList)):
                channelNum = channelNum + 1
                self.updateDialogProgress = self.updateDialogProgress + (10/len(chanlist.studioList))
                # add network presets
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "2")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", Globals.uni(chanlist.studioList[i]))
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Movie Studios",Globals.uni(chanlist.studioList[i]))

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))
        
        self.updateDialogProgress = 25
        if Globals.REAL_SETTINGS.getSetting("autoFindMovieGenres") == "true":
            self.log("autoTune, Adding Movie Genres")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Movie Genres","")
            channelNum = channelNum - 1
            for i in range(len(chanlist.movieGenreList)):
                channelNum = channelNum + 1
                self.updateDialogProgress = self.updateDialogProgress + (10/len(chanlist.movieGenreList))
                # add network presets
                if chanlist.movieGenreList[i] != '':
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "4")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", Globals.uni(chanlist.movieGenreList[i]))
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Movie Genres","Found " + Globals.uni(chanlist.movieGenreList[i]) + " Movies")
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))
        
        self.updateDialogProgress = 26
        self.log("autoTune, autoFindMixGenres " + str(Globals.REAL_SETTINGS.getSetting("autoFindMixGenres")))
        if Globals.REAL_SETTINGS.getSetting("autoFindMixGenres") == "true":
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Searching for Mixed Channels","")
            chanlist.fillMixedGenreInfo()
        
        self.updateDialogProgress = 27
        if Globals.REAL_SETTINGS.getSetting("autoFindMixGenres") == "true":
            self.log("autoTune, Adding Mixed Genres")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Mixed Genres","")
            channelNum = channelNum - 1
            for i in range(len(chanlist.mixedGenreList)):
                channelNum = channelNum + 1
                # add network presets
                if chanlist.mixedGenreList[i] != '':
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "5")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", Globals.uni(chanlist.mixedGenreList[i]))
                    Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Mixed Genres",Globals.uni(chanlist.mixedGenreList[i]) + " Mix")

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))
        
        self.updateDialogProgress = 28
        self.log("autoTune, autoFindMusicGenres " + str(Globals.REAL_SETTINGS.getSetting("autoFindMusicGenres")))
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicGenres") == "true":
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Searching for Music Channels","")
            chanlist.fillMusicInfo()

        self.updateDialogProgress = 29
        #Music Genre
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicGenres") == "true":
            self.log("autoTune, Adding Music Genres")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Music Genres","")
            i = 1
            for i in range(len(chanlist.musicGenreList)):
                channelNum = channelNum + 1
                # add network presets
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "12")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", Globals.uni(chanlist.musicGenreList[i]))
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_2", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Music Genres",Globals.uni(chanlist.musicGenreList[i]) + " Music")
        
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))
        
        #Music Videos - Last.fm user
        self.updateDialogProgress = 30
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicVideosLastFM") == "true":
            self.log("autoTune, Adding Last.FM Music Videos")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Last.FM Music Videos","")
            if channelNum == 0:
                channelNum = 1
            user = Globals.REAL_SETTINGS.getSetting("autoFindMusicVideosLastFMuser")
            lastapi = "http://api.tv.timbormans.com/user/" + user + "/topartists.xml"
            for i in range(1):
                # add Last.fm user presets
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "13")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", lastapi)
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_3", "10")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_opt_1", "Last.FM")  
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
       
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))
        
        #Music Videos - Youtube
        self.updateDialogProgress = 35
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicVideosYoutube") == "true":
            self.log("autoTune, Adding Youtube Music Videos")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Youtube Music Videos","")
            if channelNum == 0:
                channelNum = 1
            for i in range(1):
                # add HungaryRChart presets
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", "HungaryRChart")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_opt_1", "HRChart")  
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                # add BillbostdHot100 presets
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_1", "BillbostdHot100")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rule_1_opt_1", "BillbostdHot100")  
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_changed", "true")
                # add TheTesteeTop50Charts presets
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 2) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 2) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 2) + "_1", "TheTesteeTop50Charts")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 2) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 2) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 2) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 2) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 2) + "_rule_1_opt_1", "TheTesteeTop50Charts")  
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 2) + "_changed", "true")
        
            channelNum = channelNum + 3
            self.logDebug('channelNum = ' + str(channelNum))
        
        #Music Videos - VevoTV
        self.updateDialogProgress = 40
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicVideosVevoTV") == "true":
            self.log("autoTune, Adding VevoTV Music Videos")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding VevoTV Music Videos","")
            if channelNum == 0:
                channelNum = 1

            for i in range(1):
                # add VevoTV presets
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "9")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", "5400")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_2", "plugin://plugin.video.vevo_tv/?url=TIVEVSTRUS00&mode=playOfficial")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_3", "VEVO TV (US: Hits)")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_4", "Sit back and enjoy a 24/7 stream of music videos on VEVO TV.")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_opt_1", "VevoTV - Hits")  
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_type", "9")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_1", "5400")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_2", "plugin://plugin.video.vevo_tv/?url=TIVEVSTRUS01&mode=playOfficial")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_3", "VEVO TV (US: Flow)")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_4", "Sit back and enjoy a 24/7 stream of music videos on VEVO TV.")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rule_1_opt_1", "VevoTV - Flow")  
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_changed", "true")

            channelNum = channelNum + 2
            self.logDebug('channelNum = ' + str(channelNum))
        
        #Music Videos - Local
        self.updateDialogProgress = 45
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicVideosLocal") != "":
            self.log("autoTune, Adding Local Music Videos")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding Local Music Videos","")
            if channelNum == 0:
                channelNum = 1
            LocalVideo = str(Globals.REAL_SETTINGS.getSetting('autoFindMusicVideosLocal'))
            for i in range(1):
                # add Local presets
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_type", "7")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_1", "" +LocalVideo+ "")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rule_1_opt_1", "Music Videos")  
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_changed", "true")        

            channelNum = channelNum + 1
            self.logDebug('channelNum = ' + str(channelNum))
        
        #InternetTV - Strms
        self.updateDialogProgress = 50
        if Globals.REAL_SETTINGS.getSetting("autoFindInternetStrms") == "true":
            self.log("autoTune, Adding InternetTV Strms")
            self.updateDialog.update(self.updateDialogProgress,"Auto Tune","Adding InternetTV Strms","")
            if channelNum == 0:
                channelNum = 1

            for i in range(1):
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_1", "BBCWorldwide")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_4", "")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_rule_1_opt_1", "BBC World News")  
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum) + "_changed", "true")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_type", "11")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_1", "http://revision3.com/hdnation/feed/Quicktime-High-Definition")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_rule_1_opt_1", "HD Nation")  
                Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channelNum + 1) + "_changed", "true")

            channelNum = channelNum + 3
            self.logDebug('channelNum = ' + str(channelNum))
           
            if Globals.REAL_SETTINGS.getSetting("Donor_Enabled") == "true":
                try:
                    self.Donor.migrateDonor(channelNum)
                except:
                    pass
           
        Globals.ADDON_SETTINGS.writeSettings()

        #set max channels
        # chanlist.setMaxChannels()
        
        self.updateDialogProgress = 100
        # reset auto tune settings        
        Globals.REAL_SETTINGS.setSetting('Autotune', "false")
        Globals.REAL_SETTINGS.setSetting('Warning1', "false")
        Globals.REAL_SETTINGS.setSetting('autoFindLivePVR', "false")
        Globals.REAL_SETTINGS.setSetting("autoFindCustom","false")
        Globals.REAL_SETTINGS.setSetting("autoFindNetworks","false")
        Globals.REAL_SETTINGS.setSetting("autoFindStudios","false")
        Globals.REAL_SETTINGS.setSetting("autoFindTVGenres","false")
        Globals.REAL_SETTINGS.setSetting("autoFindMovieGenres","false")
        Globals.REAL_SETTINGS.setSetting("autoFindMixGenres","false")
        Globals.REAL_SETTINGS.setSetting("autoFindTVShows","false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicGenres","false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosYoutube","false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosVevoTV","false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosLastFM","false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosLocal","")
        Globals.REAL_SETTINGS.setSetting("autoFindInternetStrms","false")
        Globals.REAL_SETTINGS.setSetting("ForceChannelReset","true")

        Globals.ADDON_SETTINGS.setSetting('LastExitTime', str(int(curtime)))
        self.updateDialog.close()
Exemplo n.º 8
0
 def get_blood_by_donor(self, donor_name: str, donor_id: str) -> list:
     donor = Donor(donor_name, donor_id)
     return donor.history
Exemplo n.º 9
0
class Migrate:
    def log(self, msg, level=xbmc.LOGDEBUG):
        Globals.log('Migrate: ' + msg, level)

    def logDebug(self, msg, level=xbmc.LOGDEBUG):
        if Globals.REAL_SETTINGS.getSetting('enable_Debug') == "true":
            Globals.log('Migrate: ' + msg, level)

    def migrate(self):
        self.log("migrate")
        settingsFile = xbmc.translatePath(
            os.path.join(Globals.SETTINGS_LOC, 'settings2.xml'))
        chanlist = ChannelList.ChannelList()
        chanlist.background = True
        chanlist.forceReset = True
        chanlist.createlist = True

        # If Autotune is enabled direct to autotuning
        if Globals.REAL_SETTINGS.getSetting(
                "Autotune") == "true" and Globals.REAL_SETTINGS.getSetting(
                    "Warning1") == "true":
            self.log("autoTune, migrate")
            if self.autoTune():
                return True
        else:
            if FileAccess.exists(settingsFile):
                return False
            else:
                currentpreset = 0

            for i in range(Globals.TOTAL_FILL_CHANNELS):
                chantype = 9999

                try:
                    chantype = int(
                        Globals.ADDON_SETTINGS.getSetting("Channel_" +
                                                          str(i + 1) +
                                                          "_type"))
                except:
                    pass

                if chantype == 9999:
                    self.log("addPreset")
                    self.addPreset(i + 1, currentpreset)
                    currentpreset += 1

        return True

    def addPreset(self, channel, presetnum
                  ):  # Initial settings2.xml preset on first run when empty...
        # Youtube
        BBCWW = ['BBCWW']
        Trailers = ['Trailers']
        # RSS
        HDNAT = ['HDNAT']
        TEKZA = ['TEKZA']

        if presetnum < len(BBCWW):
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_type", "10")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_1",
                                              "BBCWorldwide")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_2",
                                              "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_3",
                                              "50")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rulecount", "1")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rule_1_id", "1")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rule_1_opt_1", "BBC World News")
        elif presetnum - len(BBCWW) < len(Trailers):
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_type", "10")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_1",
                                              "movieclips")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_2",
                                              "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_3",
                                              "50")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rulecount", "1")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rule_1_id", "1")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rule_1_opt_1", "Movie Trailers")
        elif presetnum - len(BBCWW) - len(Trailers) < len(HDNAT):
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_type", "11")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_1",
                "http://revision3.com/hdnation/feed/Quicktime-High-Definition")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_2",
                                              "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_3",
                                              "50")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rulecount", "1")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rule_1_id", "1")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rule_1_opt_1", "HD Nation")
        elif presetnum - len(BBCWW) - len(Trailers) - len(HDNAT) < len(TEKZA):
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_type", "11")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_1",
                "http://revision3.com/tekzilla/feed/quicktime-high-definition")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_2",
                                              "1")
            Globals.ADDON_SETTINGS.setSetting("Channel_" + str(channel) + "_3",
                                              "50")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rulecount", "1")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rule_1_id", "1")
            Globals.ADDON_SETTINGS.setSetting(
                "Channel_" + str(channel) + "_rule_1_opt_1", "Tekzilla")

    def autoTune(self):
        self.log('autoTune, Init')
        curtime = time.time()
        chanlist = ChannelList.ChannelList()
        chanlist.background = True
        # chanlist.needsreset = True
        chanlist.makenewlists = True
        try:
            self.Donor = Donor()
        except:
            pass
        settingsFile = xbmc.translatePath(
            os.path.join(Globals.SETTINGS_LOC, 'settings2.xml'))

        if FileAccess.exists(settingsFile):
            try:
                os.remove(settingsFile)
            except:
                self.log("autoTune, Unable to delete " + str(settingsFile))

        channelNum = 0
        updateDialogProgress = 0

        self.updateDialog = xbmcgui.DialogProgress()
        self.updateDialog.create("PseudoTV Live", "Auto Tune")

        # LiveTV - PVR
        self.updateDialogProgress = 5
        if Globals.REAL_SETTINGS.getSetting(
                "autoFindLivePVR"
        ) == "true" and Globals.REAL_SETTINGS.getSetting('xmltvLOC') != '':
            self.log("autoTune, Adding Live PVR Channels")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Live PVR Channels", "")
            CHnum = 0
            RCHnum = 0
            CHid = 0
            CHlst = ''
            CHname = ''
            CHzapit = ''
            if channelNum == 0:
                channelNum = 1
            try:
                json_query = '{"jsonrpc":"2.0","method":"PVR.GetChannels","params":{"channelgroupid":2}, "id":1}'
                json_folder_detail = chanlist.sendJSON(json_query)
                file_detail = re.compile("{(.*?)}",
                                         re.DOTALL).findall(json_folder_detail)
                self.logDebug('autoFindLivePVR, file_detail = ' +
                              str(file_detail))
                self.xmlTvFile = xbmc.translatePath(
                    os.path.join(Globals.REAL_SETTINGS.getSetting('xmltvLOC'),
                                 'xmltv.xml'))

                f = FileAccess.open(self.xmlTvFile, "rb")
                tree = ET.parse(f)
                root = tree.getroot()

                file_detail = str(file_detail)
                CHnameLST = re.findall('"label" *: *(.*?),', file_detail)
                CHidLST = re.findall('"channelid" *: *(.*?),', file_detail)
                self.logDebug('autoFindLivePVR, CHnameLST = ' + str(CHnameLST))
                self.logDebug('autoFindLivePVR, CHidLST = ' + str(CHidLST))

                for CHnum in range(len(file_detail)):
                    CHname = CHnameLST[CHnum]
                    CHname = str(CHname)
                    CHname = CHname.split('"', 1)[-1]
                    CHname = CHname.split('"')[0]
                    CHlst = (CHname + ',' + CHidLST[CHnum])
                    inSet = False
                    self.logDebug('autoFindLivePVR, CHlst.1 = ' + str(CHlst))
                    # search xmltv for channel name, then find its id
                    for elem in root.getiterator():
                        if elem.tag == ("channel"):
                            name = elem.findall('display-name')
                            for i in name:
                                RCHnum = (CHnum + 1)
                                if CHname == i.text:
                                    CHzapit = elem.attrib
                                    CHzapit = str(CHzapit)
                                    CHzapit = CHzapit.split(": '", 1)[-1]
                                    CHzapit = CHzapit.split("'")[0]
                                    CHlst = (CHlst + ',' + str(CHzapit))
                                    self.logDebug(
                                        'autoFindLivePVR, CHlst.2 = ' +
                                        str(CHlst))
                                    inSet = True

                    self.log('autoFindLivePVR, inSet = ' + str(inSet) + ' , ' +
                             str(CHlst))
                    if inSet == True:
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_type", "8")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_time", "0")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_1", CHzapit)
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_2",
                            "pvr://channels/tv/All TV channels/" + str(CHnum) +
                            ".pvr")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_3", "xmltv")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_4", "")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rulecount", "1")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rule_1_id", "1")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rule_1_opt_1",
                            CHname + ' LiveTV')
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_changed", "true")
                        channelNum = channelNum + 1

                    if inSet == False:
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_type", "9")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_time", "0")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_1", "5400")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_2",
                            "pvr://channels/tv/All TV channels/" + str(CHnum) +
                            ".pvr")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_3", CHname)
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_4",
                            "XMLTV DATA NOT FOUND")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rulecount", "1")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rule_1_id", "1")
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_rule_1_opt_1",
                            CHname + ' LiveTV')
                        Globals.ADDON_SETTINGS.setSetting(
                            "Channel_" + str(channelNum) + "_changed", "true")
                        channelNum = channelNum + 1
            except:
                pass
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        # Custom Channels
        self.updateDialogProgress = 15
        if Globals.REAL_SETTINGS.getSetting("autoFindCustom") == "true":
            self.log("autoTune, Adding Custom Channel")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Custom Channel", "")
            i = 1
            for i in range(500):
                if os.path.exists(
                        xbmc.translatePath('special://profile/playlists/video')
                        + '/Channel_' + str(i + 1) + '.xsp'):
                    self.log("autoTune, Adding Custom Video Playlist Channel")
                    channelNum = channelNum + 1
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        str(
                            xbmc.translatePath(
                                'special://profile/playlists/video/') +
                            "Channel_" + str(i + 1) + '.xsp'))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rulecount", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_id", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_opt_1",
                        Globals.uni(
                            chanlist.cleanString(
                                chanlist.getSmartPlaylistName(
                                    xbmc.translatePath(
                                        'special://profile/playlists/video') +
                                    '/Channel_' + str(i + 1) + '.xsp'))))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "PseudoTV Live",
                        "Found " + Globals.uni(
                            chanlist.getSmartPlaylistName(
                                xbmc.translatePath(
                                    'special://profile/playlists/video') +
                                '/Channel_' + str(i + 1) + '.xsp')), "")
                elif os.path.exists(
                        xbmc.translatePath('special://profile/playlists/mixed')
                        + '/Channel_' + str(i + 1) + '.xsp'):
                    self.log("autoTune, Adding Custom Mixed Playlist Channel")
                    channelNum = channelNum + 1
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        str(
                            xbmc.translatePath(
                                'special://profile/playlists/mixed/') +
                            "Channel_" + str(i + 1) + '.xsp'))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rulecount", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_id", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_opt_1",
                        Globals.uni(
                            chanlist.cleanString(
                                chanlist.getSmartPlaylistName(
                                    xbmc.translatePath(
                                        'special://profile/playlists/mixed') +
                                    '/Channel_' + str(i + 1) + '.xsp'))))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "PseudoTV Live",
                        "Found " + Globals.uni(
                            chanlist.getSmartPlaylistName(
                                xbmc.translatePath(
                                    'special://profile/playlists/mixed') +
                                '/Channel_' + str(i + 1) + '.xsp')), "")
                elif os.path.exists(
                        xbmc.translatePath('special://profile/playlists/music')
                        + '/Channel_' + str(i + 1) + '.xsp'):
                    self.log("autoTune, Adding Custom Music Playlist Channel")
                    channelNum = channelNum + 1
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        str(
                            xbmc.translatePath(
                                'special://profile/playlists/music/') +
                            "Channel_" + str(i + 1) + '.xsp'))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rulecount", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_id", "1")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_rule_1_opt_1",
                        Globals.uni(
                            chanlist.cleanString(
                                chanlist.getSmartPlaylistName(
                                    xbmc.translatePath(
                                        'special://profile/playlists/music') +
                                    '/Channel_' + str(i + 1) + '.xsp'))))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "PseudoTV Live",
                        "Found " + Globals.uni(
                            chanlist.getSmartPlaylistName(
                                xbmc.translatePath(
                                    'special://profile/playlists/music') +
                                '/Channel_' + str(i + 1) + '.xsp')), "")

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        #TV - Networks/Genres
        self.updateDialogProgress = 20
        self.log("autoTune, autoFindNetworks " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindNetworks")))
        self.log("autoTune, autoFindTVGenres " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindTVGenres")))
        if (Globals.REAL_SETTINGS.getSetting("autoFindNetworks") == "true"
                or Globals.REAL_SETTINGS.getSetting("autoFindTVGenres")
                == "true"):
            self.log("autoTune, Searching for TV Channels")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Searching for TV Channels", "")
            chanlist.fillTVInfo()

        # need to add check for auto find network channels
        self.updateDialogProgress = 21
        if Globals.REAL_SETTINGS.getSetting("autoFindNetworks") == "true":
            self.log("autoTune, Adding TV Networks")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding TV Networks", "")
            i = 1
            for i in range(len(chanlist.networkList)):
                channelNum = channelNum + 1
                # add network presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1",
                    Globals.uni(chanlist.networkList[i]))
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                self.updateDialog.update(self.updateDialogProgress,
                                         "Auto Tune", "Adding TV Network",
                                         Globals.uni(chanlist.networkList[i]))

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 22
        if Globals.REAL_SETTINGS.getSetting("autoFindTVGenres") == "true":
            self.log("autoTune, Adding TV Genres")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding TV Genres", "")
            channelNum = channelNum - 1
            for i in range(len(chanlist.showGenreList)):
                channelNum = channelNum + 1
                # add network presets
                if chanlist.showGenreList[i] != '':
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "3")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        Globals.uni(chanlist.showGenreList[i]))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "Auto Tune",
                        "Adding TV Genres",
                        Globals.uni(chanlist.showGenreList[i]) + " TV")
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 23
        self.log("autoTune, autoFindStudios " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindStudios")))
        self.log("autoTune, autoFindMovieGenres " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindMovieGenres")))
        if (Globals.REAL_SETTINGS.getSetting("autoFindStudios") == "true"
                or Globals.REAL_SETTINGS.getSetting("autoFindMovieGenres")
                == "true"):
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Searching for Movie Channels", "")
            chanlist.fillMovieInfo()

        self.updateDialogProgress = 24
        if Globals.REAL_SETTINGS.getSetting("autoFindStudios") == "true":
            self.log("autoTune, Adding Movie Studios")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Movie Studios", "")
            i = 1
            for i in range(len(chanlist.studioList)):
                channelNum = channelNum + 1
                self.updateDialogProgress = self.updateDialogProgress + (
                    10 / len(chanlist.studioList))
                # add network presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "2")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1",
                    Globals.uni(chanlist.studioList[i]))
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                self.updateDialog.update(self.updateDialogProgress,
                                         "Auto Tune", "Adding Movie Studios",
                                         Globals.uni(chanlist.studioList[i]))

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 25
        if Globals.REAL_SETTINGS.getSetting("autoFindMovieGenres") == "true":
            self.log("autoTune, Adding Movie Genres")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Movie Genres", "")
            channelNum = channelNum - 1
            for i in range(len(chanlist.movieGenreList)):
                channelNum = channelNum + 1
                self.updateDialogProgress = self.updateDialogProgress + (
                    10 / len(chanlist.movieGenreList))
                # add network presets
                if chanlist.movieGenreList[i] != '':
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "4")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        Globals.uni(chanlist.movieGenreList[i]))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "Auto Tune",
                        "Adding Movie Genres", "Found " +
                        Globals.uni(chanlist.movieGenreList[i]) + " Movies")
            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 26
        self.log("autoTune, autoFindMixGenres " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindMixGenres")))
        if Globals.REAL_SETTINGS.getSetting("autoFindMixGenres") == "true":
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Searching for Mixed Channels", "")
            chanlist.fillMixedGenreInfo()

        self.updateDialogProgress = 27
        if Globals.REAL_SETTINGS.getSetting("autoFindMixGenres") == "true":
            self.log("autoTune, Adding Mixed Genres")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Mixed Genres", "")
            channelNum = channelNum - 1
            for i in range(len(chanlist.mixedGenreList)):
                channelNum = channelNum + 1
                # add network presets
                if chanlist.mixedGenreList[i] != '':
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_type", "5")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_time", "0")
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_1",
                        Globals.uni(chanlist.mixedGenreList[i]))
                    Globals.ADDON_SETTINGS.setSetting(
                        "Channel_" + str(channelNum) + "_changed", "true")
                    self.updateDialog.update(
                        self.updateDialogProgress, "Auto Tune",
                        "Adding Mixed Genres",
                        Globals.uni(chanlist.mixedGenreList[i]) + " Mix")

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        self.updateDialogProgress = 28
        self.log("autoTune, autoFindMusicGenres " +
                 str(Globals.REAL_SETTINGS.getSetting("autoFindMusicGenres")))
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicGenres") == "true":
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Searching for Music Channels", "")
            chanlist.fillMusicInfo()

        self.updateDialogProgress = 29
        #Music Genre
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicGenres") == "true":
            self.log("autoTune, Adding Music Genres")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Music Genres", "")
            i = 1
            for i in range(len(chanlist.musicGenreList)):
                channelNum = channelNum + 1
                # add network presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "12")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1",
                    Globals.uni(chanlist.musicGenreList[i]))
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                self.updateDialog.update(
                    self.updateDialogProgress, "Auto Tune",
                    "Adding Music Genres",
                    Globals.uni(chanlist.musicGenreList[i]) + " Music")

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        #Music Videos - Last.fm user
        self.updateDialogProgress = 30
        if Globals.REAL_SETTINGS.getSetting(
                "autoFindMusicVideosLastFM") == "true":
            self.log("autoTune, Adding Last.FM Music Videos")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Last.FM Music Videos", "")
            if channelNum == 0:
                channelNum = 1
            user = Globals.REAL_SETTINGS.getSetting(
                "autoFindMusicVideosLastFMuser")
            lastapi = "http://api.tv.timbormans.com/user/" + user + "/topartists.xml"
            for i in range(1):
                # add Last.fm user presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "13")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1", lastapi)
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_3", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_opt_1", "Last.FM")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")

            channelNum = channelNum
            self.logDebug('channelNum = ' + str(channelNum))

        #Music Videos - Youtube
        self.updateDialogProgress = 35
        if Globals.REAL_SETTINGS.getSetting(
                "autoFindMusicVideosYoutube") == "true":
            self.log("autoTune, Adding Youtube Music Videos")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Youtube Music Videos", "")
            if channelNum == 0:
                channelNum = 1
            for i in range(1):
                # add HungaryRChart presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1", "HungaryRChart")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_opt_1", "HRChart")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                # add BillbostdHot100 presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_1", "BillbostdHot100")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_opt_1",
                    "BillbostdHot100")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_changed", "true")
                # add TheTesteeTop50Charts presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_1",
                    "TheTesteeTop50Charts")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rule_1_opt_1",
                    "TheTesteeTop50Charts")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_changed", "true")

            channelNum = channelNum + 3
            self.logDebug('channelNum = ' + str(channelNum))

        #Music Videos - VevoTV
        self.updateDialogProgress = 40
        if Globals.REAL_SETTINGS.getSetting(
                "autoFindMusicVideosVevoTV") == "true":
            self.log("autoTune, Adding VevoTV Music Videos")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding VevoTV Music Videos", "")
            if channelNum == 0:
                channelNum = 1

            for i in range(1):
                # add VevoTV presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "9")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1", "5400")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2",
                    "http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch1/06/prog_index.m3u8"
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_3", "VEVO TV (US: Hits)")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_4",
                    "Sit back and enjoy a 24/7 stream of music videos on VEVO TV."
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_opt_1",
                    "VevoTV - Hits")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_type", "9")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_1", "5400")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_2",
                    "http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch2/06/prog_index.m3u8"
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_3",
                    "VEVO TV (US: Flow)")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_4",
                    "Sit back and enjoy a 24/7 stream of music videos on VEVO TV."
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_opt_1",
                    "VevoTV - Flow")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_changed", "true")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_type", "9")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_1", "5400")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_2",
                    "http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch3/06/prog_index.m3u8"
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_3",
                    "VEVO TV (Nashville)")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_4",
                    "Sit back and enjoy a 24/7 stream of music videos on VEVO TV."
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_rule_1_opt_1",
                    "VevoTV - Nashville")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 2) + "_changed", "true")

            channelNum = channelNum + 3
            self.logDebug('channelNum = ' + str(channelNum))

        #Music Videos - Local
        self.updateDialogProgress = 45
        if Globals.REAL_SETTINGS.getSetting("autoFindMusicVideosLocal") != "":
            self.log("autoTune, Adding Local Music Videos")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding Local Music Videos", "")
            if channelNum == 0:
                channelNum = 1
            LocalVideo = str(
                Globals.REAL_SETTINGS.getSetting('autoFindMusicVideosLocal'))
            for i in range(1):
                # add Local presets
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_type", "7")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_1",
                    "" + LocalVideo + "")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_opt_1",
                    "Music Videos")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_changed", "true")

            channelNum = channelNum + 1
            self.logDebug('channelNum = ' + str(channelNum))

        #InternetTV - Strms
        self.updateDialogProgress = 50
        if Globals.REAL_SETTINGS.getSetting("autoFindInternetStrms") == "true":
            self.log("autoTune, Adding InternetTV Strms")
            self.updateDialog.update(self.updateDialogProgress, "Auto Tune",
                                     "Adding InternetTV Strms", "")
            if channelNum == 0:
                channelNum = 1

            for i in range(1):
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_type", "10")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_1", "BBCWorldwide")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_4", "")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_rule_1_opt_1",
                    "BBC World News")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum) + "_changed", "true")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_type", "11")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_time", "0")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_1",
                    "http://revision3.com/hdnation/feed/Quicktime-High-Definition"
                )
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_2", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_3", "50")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rulecount", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_id", "1")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_rule_1_opt_1",
                    "HD Nation")
                Globals.ADDON_SETTINGS.setSetting(
                    "Channel_" + str(channelNum + 1) + "_changed", "true")

            channelNum = channelNum + 3
            self.logDebug('channelNum = ' + str(channelNum))

            if Globals.REAL_SETTINGS.getSetting("Donor_Enabled") == "true":
                try:
                    self.Donor.migrateDonor(channelNum)
                except:
                    pass

        Globals.ADDON_SETTINGS.writeSettings()

        #set max channels
        # chanlist.setMaxChannels()

        self.updateDialogProgress = 100
        # reset auto tune settings
        Globals.REAL_SETTINGS.setSetting('Autotune', "false")
        Globals.REAL_SETTINGS.setSetting('Warning1', "false")
        Globals.REAL_SETTINGS.setSetting('autoFindLivePVR', "false")
        Globals.REAL_SETTINGS.setSetting("autoFindCustom", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindNetworks", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindStudios", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindTVGenres", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMovieGenres", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMixGenres", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindTVShows", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicGenres", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosYoutube", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosVevoTV", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosLastFM", "false")
        Globals.REAL_SETTINGS.setSetting("autoFindMusicVideosLocal", "")
        Globals.REAL_SETTINGS.setSetting("autoFindInternetStrms", "false")
        Globals.REAL_SETTINGS.setSetting("ForceChannelReset", "true")

        Globals.ADDON_SETTINGS.setSetting('LastExitTime', str(int(curtime)))
        self.updateDialog.close()
Exemplo n.º 10
0
def donor_data_manager(lista):
    donor_data = Donor.create_class()
    print("What you want to change? \n"
                      "1. name\n"
                      "2. weight\n"
                      "3. date of birth\n"
                      "4. age\n"
                      "5. last donation date\n"
                      "6. sickness\n"
                      "7. gender\n"
                      "8. unique id\n"
                      "9. expiration of id\n"
                      "10. email address\n"
                      "11. blood type\n"
                      "12. mobile_number\n"
                      "13. hemoglobin_level\n")
    order_donor=int(input("choosen:~# "))
    while order_donor not in donor_listing_order:
        print("choose from above")
        order_donor=int(input())
        ####NAME####
    if order_donor == 1:
        print("Old name:"+lista[0])
        donor_data.get_name()
        if save_or_not_answer()=="yes":
            lista[0]=donor_data.name
        else:
            return lista

        ####WEIGHT####
    if order_donor == 2:
        print("Old weight:"+lista[1])
        donor_data.get_weight()
        if save_or_not_answer()=="yes":
            lista[1]=donor_data.weight
        return lista


        ####DATE OF BIRTH####
    if order_donor == 3:
        print("Old date of birth:"+lista[2])
        donor_data.get_birth_of_date()
        if save_or_not_answer()=="yes":
            lista[2]=donor_data.date_of_birth
        else:
            return lista

        ####Age####
    if order_donor == 4:
        print("Old age:"+lista[3])
        age=""
        while age=="":
            age=input("new age: ")
            if not age.isdigit():
                age=""
        if save_or_not_answer()=="yes":
            lista[3]=age
        else:
            return lista

       ###LastDonation###
    if order_donor == 5:
        print("Old last donation date:"+lista[4])
        donor_data.get_last_donation_date()
        if save_or_not_answer()=="yes":
            lista[4]=donor_data.last_donation_date
        else:
            return lista

        ####Sickness###
    if order_donor == 6:
        print("Old sickness:"+lista[5])
        donor_data.get_sickness()
        if save_or_not_answer()=="yes":
            lista[5]=donor_data.was_sick
        else:
            return lista

        ###Gender###
    if order_donor == 7:
        print("Old gender:"+lista[6])
        donor_data.get_gender()
        if save_or_not_answer()=="yes":
            lista[6]=donor_data.gender
        else:
            return lista

        ####uniqueID###
    if order_donor == 8:
        print("Old uniqueID:"+lista[7])
        donor_data.get_unique_id()
        if save_or_not_answer()=="yes":
            lista[7]=donor_data.unique_id
        else:
            return lista

        ###expirationofid###
    if order_donor == 9:
        print("Old expiration of ID:"+lista[8])
        donor_data.get_expiration_of_id()
        if save_or_not_answer()=="yes":
            lista[8]=donor_data.expiration_of_id
        else:
            return lista

        ###emailadress#
    if order_donor == 10:
        print("Old email address:"+lista[9])
        donor_data.get_email_address()
        if save_or_not_answer()=="yes":
            lista[9]=donor_data.email_address
        else:
            return lista

        ###bloodtype###
    if order_donor == 11:
        print("Old bloody type:"+lista[10])
        donor_data.get_blood_type()
        if save_or_not_answer()=="yes":
            lista[10]=donor_data.blood_type
        else:
            return lista

        ###mobilenumber###
    if order_donor == 12:
        print("Old mobile number:"+lista[11])
        donor_data.get_mobile_number()
        if save_or_not_answer()=="yes":
            lista[11]=donor_data.mobile_number
        else:
            return lista

        ####hemoglobinlevel
    if order_donor == 13:
        print("Old hemoglobin:"+lista[12])
        hemoglobin=""
        while hemoglobin=="":
            hemoglobin=input("new hemoglobin: ")
            if not hemoglobin.isdigit():
                hemoglobin=""
        if save_or_not_answer()=="yes":
            lista[12]=hemoglobin
        else:
            return lista

    return lista
Exemplo n.º 11
0
bag3.verify("B-")

m3.addBlood(bag1)
m3.addBlood(bag2)
m3.addBlood(bag3)

bag1 = Blood(today, 250)
bag1.verify("O-")

bag2 = Blood(today, 450)
bag2.verify("O-")

bag3 = Blood(today, 350)
bag3.verify("B-")

m3.addBlood(bag1)
m3.addBlood(bag2)
m3.addBlood(bag3)

donorList.clear()

p1 = Donor("John", 2033, "AB+")
p1.verify("AB+")

p2 = Donor("David", 2035, "B+")
p2.verify("B+")

# Save to file
saveFacilities()
saveBlood()
saveDonors()