Add ability to view comments
parent
a0778cf09a
commit
8e2cbeb208
@ -0,0 +1,99 @@
|
|||||||
|
import xbmc
|
||||||
|
import xbmcgui
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from lib.general import *
|
||||||
|
from lib.rumble_user import RumbleUser
|
||||||
|
|
||||||
|
RUMBLE_USER = RumbleUser()
|
||||||
|
|
||||||
|
class CommentWindow(xbmcgui.WindowXML):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.video_id = kwargs['video_id']
|
||||||
|
xbmcgui.WindowXML.__init__(self, args, kwargs)
|
||||||
|
|
||||||
|
def onInit(self):
|
||||||
|
self.refresh()
|
||||||
|
|
||||||
|
def fetch_comment_list(self):
|
||||||
|
|
||||||
|
""" fetches comment list from rumble """
|
||||||
|
|
||||||
|
return RUMBLE_USER.get_comments( self.video_id )
|
||||||
|
|
||||||
|
def refresh(self):
|
||||||
|
|
||||||
|
""" Refreshes comment list """
|
||||||
|
|
||||||
|
ccl = self.get_comment_control_list()
|
||||||
|
|
||||||
|
results = self.fetch_comment_list()
|
||||||
|
|
||||||
|
if results:
|
||||||
|
for comment_author_url, comment_author_name, comment_id, \
|
||||||
|
comment_post_day, comment_post_month, comment_post_date, comment_post_year, \
|
||||||
|
comment_post_hour, comment_post_minute, comment_post_meridiem, \
|
||||||
|
comment_post_time_ago, comment in results:
|
||||||
|
|
||||||
|
ccl.addItem(
|
||||||
|
self.create_list_item(
|
||||||
|
comment_id,
|
||||||
|
comment_author_name,
|
||||||
|
comment_post_time_ago,
|
||||||
|
comment
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
if ccl.size() == 0:
|
||||||
|
ccl.addItem(xbmcgui.ListItem(label="No Comments Found"))
|
||||||
|
|
||||||
|
def get_comment_control_list(self):
|
||||||
|
|
||||||
|
""" gets comment control list """
|
||||||
|
|
||||||
|
return self.getControl(1)
|
||||||
|
|
||||||
|
def create_list_item(self, comment_id, comment_author_name, comment_post_time_ago, comment):
|
||||||
|
|
||||||
|
""" creates list that will view comment """
|
||||||
|
|
||||||
|
line_item = xbmcgui.ListItem(
|
||||||
|
label=self.create_label(
|
||||||
|
comment_id,
|
||||||
|
comment_author_name,
|
||||||
|
comment_post_time_ago,
|
||||||
|
comment
|
||||||
|
)
|
||||||
|
)
|
||||||
|
line_item.setProperty('id', comment_id)
|
||||||
|
line_item.setProperty('comment_author_name', comment_author_name)
|
||||||
|
line_item.setProperty('comment_post_time_ago', comment_post_time_ago)
|
||||||
|
line_item.setProperty('comment', comment)
|
||||||
|
return line_item
|
||||||
|
|
||||||
|
def refresh_label(self, line_item, selected=True):
|
||||||
|
|
||||||
|
""" Refreshes comment label """
|
||||||
|
|
||||||
|
comment_id = line_item.getProperty('id')
|
||||||
|
comment_author_name = line_item.getProperty('comment_author_name')
|
||||||
|
comment_post_time_ago = line_item.getProperty('comment_post_time_ago')
|
||||||
|
comment = line_item.getProperty('comment')
|
||||||
|
line_item.setLabel(
|
||||||
|
self.create_label(
|
||||||
|
comment_id,
|
||||||
|
comment_author_name,
|
||||||
|
comment_post_time_ago,
|
||||||
|
comment,
|
||||||
|
selected
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def create_label(self, comment_id, comment_author_name, comment_post_time_ago, comment, selected=False):
|
||||||
|
|
||||||
|
""" Creates label to view comments """
|
||||||
|
|
||||||
|
return comment_author_name + ' [COLOR white]' + clean_text( comment ) \
|
||||||
|
+ '[/COLOR] [COLOR orange](' + comment_post_time_ago + ')[/COLOR]'
|
@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<window>
|
||||||
|
<defaultcontrol always="false">1</defaultcontrol>
|
||||||
|
<menucontrol>1</menucontrol>
|
||||||
|
<backgroundcolor>0xff000000</backgroundcolor>
|
||||||
|
<animation effect="fade" time="100">WindowOpen</animation>
|
||||||
|
<animation effect="fade" time="100">WindowClose</animation>
|
||||||
|
<zorder>1</zorder>
|
||||||
|
<coordinates>
|
||||||
|
<left>0</left>
|
||||||
|
<top>0</top>
|
||||||
|
</coordinates>
|
||||||
|
<controls>
|
||||||
|
<control type="list" id="1">
|
||||||
|
<description>Comment list</description>
|
||||||
|
<left>0</left>
|
||||||
|
<top>0</top>
|
||||||
|
<visible>true</visible>
|
||||||
|
<viewtype label="Comments">list</viewtype>
|
||||||
|
<orientation>vertical</orientation>
|
||||||
|
<pagecontrol>25</pagecontrol>
|
||||||
|
<itemlayout height="28">
|
||||||
|
<control type="label">
|
||||||
|
<left>0</left>
|
||||||
|
<height>24</height>
|
||||||
|
<font>font14</font>
|
||||||
|
<aligny>center</aligny>
|
||||||
|
<textcolor>blue</textcolor>
|
||||||
|
<align>left</align>
|
||||||
|
<label>$INFO[ListItem.Label]</label>
|
||||||
|
</control>
|
||||||
|
</itemlayout>
|
||||||
|
<focusedlayout height="28">
|
||||||
|
<control type="label">
|
||||||
|
<left>0</left>
|
||||||
|
<height>24</height>
|
||||||
|
<font>font14</font>
|
||||||
|
<aligny>center</aligny>
|
||||||
|
<textcolor>red</textcolor>
|
||||||
|
<align>left</align>
|
||||||
|
<label>$INFO[ListItem.Label]</label>
|
||||||
|
<scroll>true</scroll>
|
||||||
|
<scrollspeed>250</scrollspeed>
|
||||||
|
</control>
|
||||||
|
</focusedlayout>
|
||||||
|
</control>
|
||||||
|
</controls>
|
||||||
|
</window>
|
Loading…
Reference in New Issue