Exemplo n.º 1
0
 def replyToComment(self, commentId, text, replyToComment):
   params = {'part':'snippet'}
   if(replyToComment):
     return
   else:
     data = {'snippet':{'videoId':commentId,'topLevelComment':{'snippet':{'textOriginal':text}}}}
     path = 'commentThreads'
   v3Request(method='POST', path=path, params=params, post_data=data)
   return
Exemplo n.º 2
0
 def rate(self, rate, currentRating, videoId):
   if(currentRating==rate):
     rate = 'none'
   params = {'id': videoId,
             'rating': rate}
   try:
     v3Request(method='POST', path='videos/rate', params=params)
   except json.errors.JSONDecodeError: #expected error bug in the youtube client
     return rate
   return rate
Exemplo n.º 3
0
 def preload(self):
   parts = ['snippet,statistics,liveStreamingDetails']
   params = {'part': ''.join(parts), 'id': self.videoId}
   self.videoInfo = v3Request(method='GET', path='videos', params=params)
   #self.videoId = self.videoInfo['items'][0]['id']
   self.channelInfo = getChannels(self.videoInfo['items'][0]['snippet']['channelId'])
   return [self.videoInfo, self.channelInfo]#self.getRelatedVideos(self.videoId)
Exemplo n.º 4
0
 def __init__(self, match):
     if (match):
         videoId = match.group(1)
         parts = ['snippet,statistics']
         params = {'part': ''.join(parts), 'id': videoId}
         self.videoInfo = v3Request(method='GET',
                                    path='videos',
                                    params=params)
         self.channelInfo = getChannels(
             self.videoInfo['items'][0]['snippet']['channelId'])
     return
Exemplo n.º 5
0
  def getChatMessages(self, chatDialog):
    self.videoInfo = self.getPreloadData()[0]
    try:
      self.chatId = self.videoInfo['items'][0]['liveStreamingDetails']['activeLiveChatId']
    except:
      xbmcgui.Dialog().ok("Failed to get live chat", "No live chat available")
    self.stop = False
    parts = ['snippet,authorDetails']
    params = {'part': ''.join(parts), 'liveChatId': self.chatId}

    messages = v3Request(method='GET', path='liveChat/messages', params=params)
    
    while not self.stop:
      for item in messages['items']:
        msg = {}
        msg['author'] = item['authorDetails']['displayName']
        msg['date'] = item['snippet']['publishedAt']
        msg['value'] = item['snippet']['displayMessage']
        msg['thumb'] = item['authorDetails']['profileImageUrl']
        chatDialog.updateContent(msg)
      waitTime = messages['pollingIntervalMillis']
      time.sleep(waitTime/1000)
      params['pageToken'] = messages['nextPageToken']
      messages = v3Request(method='GET', path='liveChat/messages', params=params)
Exemplo n.º 6
0
 def showComments(self, videoId, page=None):
     params = {
         'part': 'snippet',
         'videoId': videoId,
         'order': 'relevance',
         'textFormat': 'plainText',
         'maxResults': '50'
     }
     if page:
         params['pageToken'] = page
     result = v3Request(method='GET',
                        path='commentThreads',
                        params=params,
                        no_login=True)
     diaogText = self.getTextForCommentsDialog(result)
     xbmc.Dialog().textviewer('Comments', dialogText)
Exemplo n.º 7
0
 def myGetRelatedVideos(self, videoId):
   params = {'relatedToVideoId': videoId,
             'part': 'snippet',
             'type': 'video',
             'maxResults': str(20)}
   return v3Request(method='GET', path='search', params=params)['items']
Exemplo n.º 8
0
 def getRating(self, videoId):
   params = {'id': videoId}
   return v3Request(method='GET', path='videos/getRating', params=params)['items'][0]['rating']
Exemplo n.º 9
0
 def replyToChat(self, text):
   params = {'part':'snippet'}
   data= {'snippet':{'liveChatId': str(self.chatId),'type':'textMessageEvent','textMessageDetails':{'messageText':text}}}
   v3Request(method='POST', path='liveChat/messages', params=params, post_data=data)
   return