コード例 #1
0
ファイル: objects.py プロジェクト: Rahix/lollypop-transparent
 def set_popularity(self, new_rate):
     """
         Set popularity
         @param new_rate as int between 0 and 5
     """
     if self.id is None:
         return
     try:
         if self.id >= 0:
             avg_popularity = self.db.get_avg_popularity()
             popularity = int((new_rate * avg_popularity / 5) + 0.5)
             best_popularity = self.db.get_higher_popularity()
             if new_rate == 5:
                 popularity = (popularity + best_popularity) / 2
             self.db.set_popularity(self.id, popularity)
         elif self.id == Type.RADIOS:
             radios = Radios()
             avg_popularity = radios.get_avg_popularity()
             popularity = int((new_rate * avg_popularity / 5) + 0.5)
             best_popularity = self.db.get_higher_popularity()
             if new_rate == 5:
                 popularity = (popularity + best_popularity) / 2
             radios.set_popularity(self._radio_id, popularity)
     except Exception as e:
         Logger.error("Base::set_popularity(): %s" % e)
コード例 #2
0
ファイル: objects.py プロジェクト: blackjackshellac/lollypop
 def set_popularity(self, popularity):
     """
         Set popularity
         @param popularity as int between 0 and 5
     """
     if self.id is None or self.id == Type.EXTERNALS:
         return
     try:
         if self.id >= 0:
             avg_popularity = self.db.get_avg_popularity()
             popularity = int((popularity * avg_popularity / 5) + 0.5)
             self.db.set_popularity(self.id, popularity, True)
         elif self.id == Type.RADIOS:
             radios = Radios()
             avg_popularity = radios.get_avg_popularity()
             popularity = int((popularity * avg_popularity / 5) + 0.5)
             radios.set_popularity(self._album_artists[0], popularity)
     except Exception as e:
         print("Base::set_popularity(): %s" % e)
コード例 #3
0
 def set_popularity(self, popularity):
     """
         Set popularity
         @param popularity as int between 0 and 5
     """
     if self.id is None or self.id == Type.EXTERNALS:
         return
     try:
         if self.id >= 0:
             avg_popularity = self.db.get_avg_popularity()
             popularity = int((popularity * avg_popularity / 5) + 0.5)
             self.db.set_popularity(self.id, popularity, True)
         elif self.id == Type.RADIOS:
             radios = Radios()
             avg_popularity = radios.get_avg_popularity()
             popularity = int((popularity * avg_popularity / 5) + 0.5)
             radios.set_popularity(self._album_artists[0], popularity)
     except Exception as e:
         print("Base::set_popularity(): %s" % e)