martastain

nxtv logo plugin

May 19th, 2021
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. from nebula import *
  2.  
  3. class Plugin(PlayoutPlugin):
  4.     def on_init(self):
  5.         self.id_layer = 99
  6.         self.logo = False
  7.         self.slots = [
  8.                 PlayoutPluginSlot("action", "show"),
  9.                 PlayoutPluginSlot("action", "hide")
  10.             ]
  11.         self.tasks = [
  12.                 self.on_change
  13.             ]
  14.  
  15.     def on_change(self):
  16.         if not self.current_asset and self.current_item and self.current_item["item_role"] == "live":
  17.             return self.show_live()
  18.         elif self.current_asset["id_folder"] in [9, 10]:
  19.             return self.hide()
  20.         else:
  21.             return self.show()
  22.  
  23.     def on_command(self, action, **kwargs):
  24.         if action == "hide":
  25.             self.hide()
  26.             return True
  27.  
  28.         if action == "show":
  29.             self.show()
  30.         return True
  31.  
  32.     def show(self):
  33.         logo = "nxtv-logo"
  34.         if self.query("PLAY {} {} MIX 4".format(self.layer(), logo)):
  35.             logging.info("Switched station logo to {}".format(logo))
  36.             self.logo = logo
  37.             return True
  38.         logging.error("Logo show failed")
  39.  
  40.     def show_live(self):
  41.         logo = "nxtv-logo-live"
  42.         logging.info("Switching station logo to {}".format(logo))
  43.         if self.query("PLAY {} {} MIX 4".format(self.layer(), logo)):
  44.             self.logo = logo
  45.             return True
  46.         logging.error("Logo show failed")
  47.  
  48.  
  49.     def hide(self):
  50.         logo = "EMPTY"
  51.         logging.info("Hiding station logo")        
  52.         if self.query("PLAY {} {} MIX 4".format(self.layer(), logo)):
  53.             self.logo = logo
  54.             return True
  55.         logging.error("Logo hide failed")
Add Comment
Please, Sign In to add comment