Exemple #1
0
    def deleteBouquets(self, answer=None):
        if answer is None:
            self.session.openWithCallback(
                self.deleteBouquets, MessageBox,
                _('Permanently delete all Jedi created bouquets?'))
        elif answer:
            with open('/etc/enigma2/bouquets.tv', 'r+') as f:
                lines = f.readlines()
                f.seek(0)
                for line in lines:
                    if 'jmx' not in line:
                        f.write(line)
                f.truncate()

            jfunc.purge('/etc/enigma2', 'jmx')

            if jglob.has_epg_importer:
                jfunc.purge('/etc/epgimport', 'jmx')

            self.playlists_all = jfunc.getPlaylistJson()

            jglob.bouquets_exist = False
            jfunc.resetUnique()
            jglob.firstrun = 0
            jglob.current_selection = 0
            jglob.current_playlist = []

            # delete leftover empty dicts
            self.playlists_all = filter(None, self.playlists_all)

            os.remove(playlist_file)
            jfunc.refreshBouquets()

            self.createSetup()
        return
Exemple #2
0
def buildXMLTVChannelFile(epg_name_list):

    cleanName = re.sub(r'[\<\>\:\"\/\\\|\?\*]', '_', str(jglob.name))
    cleanName = re.sub(r' ', '_', cleanName)
    cleanName = re.sub(r'_+', '_', cleanName)

    cleanNameOld = re.sub(r'[\<\>\:\"\/\\\|\?\* ]', '_', str(jglob.old_name))
    cleanNameOld = re.sub(r' ', '_', cleanNameOld)
    cleanNameOld = re.sub(r'_+', '_', cleanNameOld)

    # remove old files
    jfunc.purge('/etc/epgimport', 'jmx.' + str(cleanName) + '.channels.xml')
    jfunc.purge('/etc/epgimport', 'jmx.' + str(cleanNameOld) + '.channels.xml')

    jfunc.purge('/etc/epgimport', 'jmx.' + str(cleanName) + '.sources.xml')
    jfunc.purge('/etc/epgimport', 'jmx.' + str(cleanNameOld) + '.sources.xml')

    filepath = '/etc/epgimport/'
    epgfilename = 'jmx.' + str(cleanName) + '.channels.xml'
    channelpath = filepath + epgfilename

    bouquetfilepath = '/etc/enigma2/'
    root = ET.Element('channels')

    # if xmltv file doesn't already exist, create file and build.
    if not os.path.isfile(channelpath):
        open(channelpath, 'a').close()

        for i in range(len(epg_name_list)):
            newchannel = ET.SubElement(root, 'channel')
            newchannel.set('id', epg_name_list[i][0])
            newchannel.text = epg_name_list[i][1]

        xml_str = str(ET.tostring(root, 'utf-8'))
        doc = minidom.parseString(xml_str)
        xml_output = doc.toprettyxml(encoding='utf-8', indent='')
        xml_output = os.linesep.join(
            [s for s in xml_output.splitlines() if s.strip()])
        with open(channelpath, 'w') as f:
            f.write(xml_output)
    else:
        tree = ET.parse(channelpath)
        root = tree.getroot()
        e = str(ET.tostring(root, 'utf-8'))

        for channel in root.findall('channel'):
            root.remove(channel)

        for i in range(len(epg_name_list)):
            newchannel = ET.SubElement(root, 'channel')
            newchannel.set('id', epg_name_list[i][0])
            newchannel.text = epg_name_list[i][1]

        xml_str = str(ET.tostring(root, 'utf-8'))
        doc = minidom.parseString(xml_str)
        xml_output = doc.toprettyxml(encoding='utf-8', indent='')
        xml_output = os.linesep.join(
            [s for s in xml_output.splitlines() if s.strip()])
        with open(channelpath, 'w') as f:
            f.write(xml_output)
def downloadXMLTV():

    cleanName = re.sub(r'[\<\>\:\"\/\\\|\?\*]', '_', str(jglob.name))
    cleanName = re.sub(r' ', '_', cleanName)
    cleanName = re.sub(r'_+', '_', cleanName)

    cleanNameOld = re.sub(r'[\<\>\:\"\/\\\|\?\* ]', '_', str(jglob.old_name))
    cleanNameOld = re.sub(r' ', '_', cleanNameOld)
    cleanNameOld = re.sub(r'_+', '_', cleanNameOld)

    jfunc.purge('/etc/epgimport', 'jmx.' + str(cleanName) + '.xmltv.xml')
    jfunc.purge('/etc/epgimport', 'jmx.' + str(cleanNameOld) + '.xmltv.xml')
    jfunc.purge('/etc/epgimport', 'jmx.' + str(cleanName) + '.xmltv2.xml')
    jfunc.purge('/etc/epgimport', 'jmx.' + str(cleanNameOld) + '.xmltv2.xml')

    filepath = '/etc/epgimport/'
    epgfilename = 'jmx.' + str(cleanName) + '.xmltv.xml'
    epgpath = filepath + epgfilename
    response = downloads.checkGZIP(jglob.xmltv_address)

    if response != None:

        with open(epgpath, 'w') as f:
            f.write(response)

        with open(epgpath, 'r') as f:
            #tree = ET.parse(f)
            tree = ET.parse(f, parser=ET.XMLParser(encoding='utf-8'))

        tree.write('/etc/epgimport/' + 'jmx.' + str(cleanName) + '.xmltv2.xml',
                   encoding='utf-8',
                   xml_declaration=True)
Exemple #4
0
    def deleteBouquets(self):
        selectedBouquetList = self.getSelectionsList()

        for x in selectedBouquetList:
            bouquet_name = x

            cleanName = re.sub(r'[\<\>\:\"\/\\\|\?\*]', '_', str(bouquet_name))
            cleanName = re.sub(r' ', '_', cleanName)
            cleanName = re.sub(r'_+', '_', cleanName)

            with open('/etc/enigma2/bouquets.tv', 'r+') as f:
                lines = f.readlines()
                f.seek(0)
                for line in lines:
                    if 'jmx_live_' + str(
                            cleanName) + "_" in line or 'jmx_vod_' + str(
                                cleanName
                            ) + "_" in line or 'jmx_series_' + str(
                                cleanName) + "_" in line or 'jmx_' + str(
                                    cleanName) in line:
                        continue
                    f.write(line)
                f.truncate()

            jfunc.purge('/etc/enigma2', 'jmx_live_' + str(cleanName) + "_")
            jfunc.purge('/etc/enigma2', 'jmx_vod_' + str(cleanName) + "_")
            jfunc.purge('/etc/enigma2', 'jmx_series_' + str(cleanName) + "_")
            jfunc.purge('/etc/enigma2', str(cleanName) + str('.tv'))

            if jglob.has_epg_importer:
                jfunc.purge('/etc/epgimport',
                            'jmx.' + str(cleanName) + '.channels.xml')
                jfunc.purge('/etc/epgimport',
                            'jmx.' + str(cleanName) + '.sources.xml')

            jfunc.refreshBouquets()
            self.deleteBouquetFile(bouquet_name)
            jglob.firstrun = 0
            jglob.current_selection = 0
            jglob.current_playlist = []
        self.close()