Beispiel #1
0
    def __init__(self, channel=Config.CHANNEL_NAME):
        self.channel = channel
        self.broadcaster_language = None
        self.game = None
        self.mature = None
        # Title of the stream
        self.status = None

        # Values retrieved from API
        self.followers = None
        self.subscribers = None
        self.moderators = []
        self.views = None

        # Database channel data
        self.media_requests = []
        self.polls = []
        self.quotes = []
        self.commands = []
        self.timers = []
        self.banned_words = []

        self.dbconn = Db(database="brexbot",
                         host="198.71.225.59",
                         port=3306,
                         username="******",
                         password="******")
        self.api = TwitchApi(self.channel)
Beispiel #2
0
 def __init__(self):
     super(GUI, self).__init__()
     self.helper = TwitchGUIHelper()
     self.layout = None
     self.main_content_box = None
     self.player = TwitchPlayer()
     self.twitch_api = TwitchApi()
     # Init Functions
     self.init_ui()
Beispiel #3
0
class GUI(QtGui.QDialog):
    def __init__(self):
        super(GUI, self).__init__()
        self.helper = TwitchGUIHelper()
        self.layout = None
        self.main_content_box = None
        self.player = TwitchPlayer()
        self.twitch_api = TwitchApi()
        # Init Functions
        self.init_ui()

    def init_ui(self):
        self.setWindowTitle("Twitcherino")
        self.setStyleSheet("QDialog{background-color:#1f1f1f;}")

        self.layout = QtGui.QHBoxLayout()

        self.main_content_box = self.create_main_wrapper()

        self.layout.addWidget(self.create_menu_box())
        self.layout.addWidget(self.main_content_box, alignment=QtCore.Qt.AlignRight)

        self.setLayout(self.layout)
        self.show()

    def create_menu_box(self):
        hbox = QtGui.QGroupBox()
        hbox.setMinimumWidth(200)
        hbox.setMaximumWidth(200)

        h_layout = QtGui.QVBoxLayout()
        hbox.setStyleSheet("QGroupBox{ border:none;color:#9b9b9b;}")

        logo = create_label_image("/img/logo.png")
        h_layout.addWidget(logo, alignment=QtCore.Qt.AlignCenter)

        top_streams_btn = create_push_button("Channels", click=lambda: self.show_channels())
        h_layout.addWidget(top_streams_btn)

        game_list_btn = create_push_button("Games", click=lambda: self.show_games_list())
        h_layout.addWidget(game_list_btn)

        btn_close = create_push_button("Exit", click=Qt.QApplication.instance().quit)
        h_layout.addWidget(btn_close, alignment=QtCore.Qt.AlignBottom)

        hbox.setLayout(h_layout)
        return hbox

    def show_channels(self):
        clear_layout(self.helper.get_main_content_layout())
        QtCore.QObjectCleanupHandler().add(self.helper.get_main_content_layout())
        streams = self.twitch_api.get_streams(limit=12)
        self.helper.set_main_content_layout(self.helper.create_streams_layout(streams["streams"], self.player))
        self.main_content_box.setLayout(self.helper.get_main_content_layout())

    def show_streams_by_game(self, game):
        clear_layout(self.helper.get_main_content_layout())
        QtCore.QObjectCleanupHandler().add(self.helper.get_main_content_layout())
        streams = self.twitch_api.get_game_streams(game, limit=12)
        self.helper.set_main_content_layout(self.helper.create_streams_layout(streams["streams"], self.player))
        self.main_content_box.setLayout(self.helper.get_main_content_layout())

    def show_games_list(self):
        clear_layout(self.helper.get_main_content_layout())
        QtCore.QObjectCleanupHandler().add(self.helper.get_main_content_layout())
        games = self.twitch_api.get_games(limit=24)
        self.helper.set_main_content_layout(self.helper.create_games_list_layout(games, self.show_streams_by_game))
        self.main_content_box.setLayout(self.helper.get_main_content_layout())

    def create_main_wrapper(self):
        grid_box = QtGui.QGroupBox()
        grid_box.setStyleSheet("QGroupBox{border:none;color:#9b9b9b;background:#f9f9f9;}")
        streams = self.twitch_api.get_streams(limit=12)
        self.helper.set_main_content_layout(self.helper.create_streams_layout(streams["streams"], self.player))
        grid_box.setLayout(self.helper.get_main_content_layout())
        return grid_box
Beispiel #4
0
 def test_get_user_id(self):
     self.test = TwitchApi().get_user_id(Config.CHANNEL_NAME)
     self.assertNotEqual(int(self.test), None)
     return self.test
Beispiel #5
0
 def test_is_follower(self):
     followers = TwitchApi().get_followers()
     first_follower = followers[0]
     test_is_follower = TwitchApi().is_follower(first_follower)
     self.assertNotEqual(None, test_is_follower)
Beispiel #6
0
 def test_is_not_moderator(self):
     test_is_moderator = TwitchApi().is_moderator("BeeJeey")
     self.assertEqual(test_is_moderator, False)
Beispiel #7
0
 def test_is_moderator(self):
     moderators = TwitchApi().get_moderators()
     first_moderator = moderators[0]
     test_is_moderator = TwitchApi().is_moderator(first_moderator)
     self.assertEqual(test_is_moderator, True)
Beispiel #8
0
 def test_get_moderators(self):
     self.test_moderators = TwitchApi().get_moderators()
     self.assertEqual(self.test_moderators, ['ToMiSmE'])
Beispiel #9
0
 def test_get_channel_id(self):
     channel_id = TwitchApi().get_channel_id(Config.CHANNEL_NAME)
     self.assertEqual(channel_id, self.test_get_user_id())
Beispiel #10
0
 def test_get_user_data(self):
     data_test = TwitchApi().get_user_data(Config.CHANNEL_NAME)
     self.assertNotEqual(data_test, None)