Jump to content


Photo

Current Bouquet Name in Python


  • Please log in to reply
1 reply to this topic

#1 microboi37

  • Senior Member
  • 74 posts

0
Neutral

Posted 13 November 2017 - 17:43

Hi all.

 

I've discovered that getting the current service name in python is fairy simple:

service = self.session.nav.getCurrentService()
info = service.info()
print info.getName()

and voila.

 

But how to get the current bouquet name?



Re: Current Bouquet Name in Python #2 pzanone

  • Senior Member
  • 202 posts

+10
Neutral

Posted 18 November 2017 - 19:04

I am interested ..
this

    def getBouquetList(self):
        self.service_types = service_types_tv
        if config.usage.multibouquet.value:
            self.bouquet_rootstr = '1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'
        else:
            self.bouquet_rootstr = '%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet' % self.service_types
        self.bouquet_root = self.getPhysicalFilenamesFromServicereference(eServiceReference('1:7:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'))
        
        bouquets = []
        serviceHandler = eServiceCenter.getInstance()
        if config.usage.multibouquet.value:
            list = serviceHandler.list(self.bouquet_root)
            if list:
                while True:
                    s = list.getNext()
                    if not s.valid():
                        break
                    if s.flags & eServiceReference.isDirectory:
                        info = serviceHandler.info(s)
                        if info:
                            bouquets.append((info.getName(s), s))

                return bouquets
        else:
            info = serviceHandler.info(self.bouquet_root)
            if info:
                bouquets.append((info.getName(self.bouquet_root), self.bouquet_root))
            return bouquets
        return None

or that?

    def readBouquetsList(self):
        try:
            f = open('/etc/enigma2/bouquet.tv')
        except Exception as e:
            print e
            return

        ret = []
        while True:
            line = f.readline()
            if line == '':
                break
            if line[:8] != '#SERVICE':
                continue
            tmp = line.strip().split(':')
            line = tmp[len(tmp) - 1]
            filename = None
            if line[:12] == 'FROM BOUQUET':
                tmp = line[13:].split(' ')
                filename = tmp[0].strip('"')
            else:
                filename = line
            if filename:
                try:
                    fb = open('/etc/enigma2/' + filename)
                except Exception as e:
                    continue

                tmp = fb.readline().strip()
                if tmp[:6] == '#NAME ':
                    ret.append([filename, tmp[6:]])
                else:
                    ret.append([filename, filename])
                fb.close()

        return ret 

no simple solution ....




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users