Example #1
0
def router(paramstring):

    # Parse a URL-encoded paramstring to the dictionary of
    # {<parameter>: <value>} elements

    params = dict(parse_qsl(paramstring[1:]))

    print "My sense are tickling.. Getting actions... Action received. Action = " + str(params)

    try:
        searchQuery = params['query']
    except:
        searchQuery = ''
    if searchQuery:
        print "WOOOOOOOOOOOOOOOOOOOOOOOOO. GOD SEARCH QUERY ====== %s" % searchQuery

    # Check the parameters passed to the plugin
    if params:
        if params['action'] == 'recentMovies':
            showMoviesList()
            
        elif params['action'] == 'search':
            try:
                k = xbmc.Keyboard('', 'Search Movies', False)
                k.doModal()
                query = k.getText() if k.isConfirmed() else None
                query = query.strip()
                if query == None or query == '':
                    return
                
                mHub = cinehub()
                mInfo = mHub.getSearchedMovieList(query)
                showSearchResult(mInfo)
            except:
                pass
                
        elif params['action'] == 'play':
            play_video(params['video'])
            
        elif params['action'] == 'playStream':
            print "all params : " + params['title']
            
            if params.has_key('imdbid'):
                play_stream(params['title'], params['year'], params['video'], params['imdbid'])
            else:
                play_stream(params['title'], params['year'], params['video'])
            
        elif params['action']=='recentMoviesWithPage':
            showMoviesList(params['page'])
            
        elif params['action'] == 'addToLibrary':
            print "plugin.video.cinehub: " + params['title']
            addMovieToLibrary(params['title'], params['year'], params['url'], params['imdbid'])

        elif params['action'] =='updateLibrary':
            if not xbmc.getCondVisibility('Library.IsScanningVideo'):
                xbmc.executebuiltin('UpdateLibrary(video)')

            
    else:

        showCatagoryList()
Example #2
0
def showMoviesList(page=1):
    xbmcplugin.setContent(addon_handle, 'movies')
    
    myHub = cinehub()
    listOfMovies = myHub.getRecentMovieList(page)
    
    listing = []
    
    for movie in listOfMovies:
    
        url = '{0}?action=play&video={1}'.format(__url__, movie.url)
        
        
        bPosterImage =  "https://image.tmdb.org/t/p/w396%s" % movie.posterImage
        bBackdropImage = "https://image.tmdb.org/t/p/w780%s" % movie.backdropImage
        sPosterImage = "https://image.tmdb.org/t/p/w185%s" % movie.posterImage
        
        trailer_url = ''
        if movie.trailer:
            trailer_url = 'plugin://plugin.video.youtube/play/?video_id=%s' % movie.trailer 
        
        li = xbmcgui.ListItem(label=movie.title, thumbnailImage=sPosterImage)
        
        li.setArt({ 'poster': bPosterImage, 'fanart' : bBackdropImage, 'thumb' : sPosterImage })
        
        info = {
            'genre': movie.genres,
            'year': movie.year,
            'title': movie.title,
            'mediatype' : 'movie',
            'code' : movie.imdbid,
            'plot' : movie.overview,
            'rating' : movie.rating,
            'tagline' : movie.tagline,
            'duration' : movie.runtime,
            'premiered' : movie.releaseDate,
            'votes' : movie.totalVote,
            'castandrole' : movie.castandrole,
            'director' : movie.director,
            'writer' : movie.writer,
            'trailer' : trailer_url
        }
        
        li.setInfo('video', info)
        
        # add video info if available 
        
        # from database myvideos93 table files get id_file
        # stream details idFile search and check if iVideoWidth has any value
        # database location: userdata/database
        hasResolutionData = 0
        
        dburl = urldb = os.path.join(xbmc.translatePath("special://userdata/Database/MyVideos93.db"))
        dbcon = sqlite3.connect(dburl)
        dbcur = dbcon.cursor()
        
        searchUrl = "plugin://plugin.video.cinehub/?action=play&video=%s" % movie.url
        dbcur.execute("SELECT * FROM files WHERE strFilename = ? " , (searchUrl,))
        result = dbcur.fetchone()
        if result:
            idFile = result[0]
            print "idFile is " + str(idFile)
            dbcur.execute("SELECT * FROM streamdetails WHERE idFile = ? " , (idFile,))
            fResult = dbcur.fetchone()
            if fResult:
                iStreamType = fResult[1]
                if iStreamType == 0:
                    hasResolutionData = 1
                    print "Found video resolution info for moovie : " + movie.title
                
        if hasResolutionData == 0:
            if movie.url.find('720p') != -1 :
                li.addStreamInfo('video', { 'width' : 1280 , 'height': 720 })
            if movie.url.find('1080p') != -1:
                li.addStreamInfo('video', { 'width' : 1920 , 'height': 1080 })
        
        li.setProperty('IsPlayable', 'true')
        
        
        # add contex menu
        cm =[]
        cm.append(('Movie Informatiom', 'Action(Info)'))
        msg = 'RunPlugin({0}?action=addToLibrary&imdbid={1}&title={2}&year={3}&url={4})'.format(__url__, movie.imdbid, urllib.quote_plus(movie.title), movie.year, movie.url)
        cm.append(('Add To Library', msg))
        li.addContextMenuItems(cm, False)
        
        listing.append((url, li , False ))
    
    
    # Next page link action
    # added as a listitem
    new_page = int(page) + 1
    newStrPage = str(new_page)
    url = '{0}?action=recentMoviesWithPage&page={1}'.format(__url__, newStrPage)
    li = xbmcgui.ListItem(label="Next Page")
    li.setArt({'thumb' : os.path.join(artPath, 'next.jpg') })
    listing.append((url, li, True))
    
    
    xbmcplugin.addDirectoryItems(addon_handle, listing, len(listing))
    
    xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)