Kodi Community Forum

Full Version: Newbie Coder
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I apologize if this has been asked before, but I've been trying to sort this issue out all morning.

If I wanted to play a youtube video. Where would I put the player code? Also, what would that code look like?

Below is the following code:

PHP Code:
import os
import sys
import urllib
import urlparse
import xbmcgui
import xbmcaddon
import xbmcplugin

class Plugin():
    
def __init__(self):
        
self._parsed sys.argv[0]
        
self._handle int(sys.argv[1])
        
self._params urlparse.parse_qs(sys.argv[2][1:])

        
self._addon xbmcaddon.Addon('plugin.video.fsociety')
        
        
self._addon_path self._addon.getAddonInfo('path')
        
self._media_path os.path.join(xbmc.translatePath(self._addon_path), 'resources''media')
        
self._playlist_path os.path.join(xbmc.translatePath(self._addon_path), 'resources''playlists')
        
        
xbmcplugin.setContent(self._handle'movies')
        
self._mode self._params.get('mode'None)
        
        if 
self._mode is None:
            
listing = []
            
listing.append(['folder''Credits'self._addon.getAddonInfo('icon'), 'fanart'])
            
listing.append(['folder''Documentaries'self._media_path '/docs.png''fanart'])
            
listing.append(['folder''Music'self._media_path '/music.png''fanart'])
            
listing.append(['folder''Films'self._media_path '/films.png''fanart'])
            
            for 
modefoldernameiconfanart in listing:
                
self._url self.buildUrl({'mode'mode'foldername'foldername})
                
self._li xbmcgui.ListItem(foldernameiconImage=icon)
                
self._li.setArt({'fanart'self._addon.getAddonInfo(fanart)})
                
xbmcplugin.addDirectoryItem(handle=self._handleurl=self._urllistitem=self._liisFolder=True)
            
            
xbmc.executebuiltin('Container.SetViewMode(500)')
            
xbmcplugin.endOfDirectory(self._handle)
        
elif self._mode[0] == 'folder':
            
foldername self._params['foldername'][0]
            if 
foldername == 'Credits':
                
file open(self._addon_path '/credits.txt')
                
                for 
line in file:
                    
url '#'
                    
li xbmcgui.ListItem(label=lineiconImage=self._addon.getAddonInfo('icon'))
                    
li.setArt({'fanart'self._addon.getAddonInfo('fanart')})
                    
xbmcplugin.addDirectoryItem(handle=self._handleurl=urllistitem=li)
                
file.close()
            
elif foldername == 'Documentaries':
                
self.addDirectoryItem('/docs.txt')
            
elif foldername == 'Music':
                
self.addDirectoryItem('/music.txt')
            
elif foldername == 'Films':
                
self.addDirectoryItem('/films.txt')
            
            
xbmc.executebuiltin('Container.SetViewMode(50)')
            
xbmcplugin.endOfDirectory(self._handle)
    
    
def buildUrl(selfquery):
        return 
self._parsed '?' urllib.urlencode(query)
    
    
def addDirectoryItem(selffilename):
        
file open(self._playlist_path filename)
        
        
listing = []
        for 
line in file:
            
listing.append(eval(line))
        
        for 
titlevideoimage in listing:
            if 
image == '':
                
image self._addon.getAddonInfo('icon')
            
url video
            li 
xbmcgui.ListItem(label=titleiconImage=image)
            
li.setArt({'fanart'self._addon.getAddonInfo('fanart')})
            
xbmcplugin.addDirectoryItem(handle=self._handleurl=urllistitem=li)
        
file.close()

if 
__name__ == '__main__':
    
Plugin()