예제 #1
0
def home(defaultFolder, myFolder):
    items = ItemList()

    items.addFolder(defaultFolder, defaultCollectionsVisual)
    items.addFolder(myFolder, myCollectionsVisual)
    items.addCustomFolder(router.browseForSourcesUrl(), browseForSourcesVisual)

    items.present(VIEW_STYLE)
예제 #2
0
def listSources(collectionFile):
    collection = loader.load(collectionFile)
    items = ItemList()
        
    for source in collection.sources:
        items.addSource(source, collectionFile, sourcesVisual)
        
    items.present(viewStyle)
def select():
    items = ItemList()

    items.addCustomFolder(router.searchYoutubedUrl(SearchType.CHANNEL),
                          channelsVisual)
    items.addCustomFolder(router.searchYoutubedUrl(SearchType.PLAYLIST),
                          playlistsVisual)
    items.addCustomFolder(router.searchYoutubedUrl(SearchType.BOTH),
                          bothVisual)

    items.present(viewStyle)
예제 #4
0
def home(defaultFolder, myFolder):
    items = ItemList()
    
    items.addFolder(defaultFolder, defaultCollectionsVisual)
    items.addFolder(myFolder, myCollectionsVisual)
    items.addCustomFolder(router.browseForSourcesUrl(), browseForSourcesVisual)

    items.present(VIEW_STYLE)
def select():
    items = ItemList()
    
    items.addCustomFolder(router.searchYoutubedUrl(SearchType.CHANNEL), channelsVisual)
    items.addCustomFolder(router.searchYoutubedUrl(SearchType.PLAYLIST), playlistsVisual)
    items.addCustomFolder(router.searchYoutubedUrl(SearchType.BOTH), bothVisual)
    
    items.present(viewStyle)
예제 #6
0
def browse(collectionFile):
    collection = Collection.fromFile(collectionFile)
    items = ItemList()

    if collection.onClick() == occ.SOURCES:
        items.addCollection(collection, feedVisual, occ.FEED)

    for cSource in collection.cSources:
        items.addCollectionSource(cSource)

    items.present(collection.sourcesSettings.viewStyle())
def browse(channelFile, pageNum):
    channel = Channel.fromCacheFile(channelFile)

    items = ItemList()
    playlists = channel.playlists

    for playlist in playlists.updatedPageItems(pageNum):
        items.addYoutubePlaylist(playlist, playlistsVisual)

    if playlists.hasPage(pageNum + 1):
        items.addYoutubeChannelPlaylists(channel, nextPageVisual, pageNum + 1)

    items.present(viewStyle)
예제 #8
0
def browse(folder):
    items = ItemList()
    files, subfolders = folder.listFolder()

    for subfolder in subfolders:
        if subfolder.name != "_images":
            items.addFolder(subfolder, foldersVisual)

    for collectionFile in files:
        collection = Collection.fromFile(collectionFile, loadSources=False)
        items.addCollection(collection, collectionsVisual, deleteContext=True)

    items.present(viewStyle)
def browse(collectionFile):
    collection = Collection.fromFile(collectionFile)
    items = ItemList()
    
    if collection.onClick() == occ.SOURCES:
        items.addCollection(collection, feedVisual, occ.FEED)
        
    for cSource in collection.cSources:
        items.addCollectionSource(cSource)
        
    items.present(collection.sourcesSettings.viewStyle())
def browse(categoryFile, pageNum):
    category = Category.fromCacheFile(categoryFile)
    
    
    items = ItemList()
    channels = category.channels
    
    for channel in channels.updatedPageItems(pageNum):
        items.addYoutubeChannel(channel, channelsVisual)
        
        
    if channels.hasPage(pageNum+1):
        items.addYoutubeCategory(category, nextPageVisual, pageNum+1)
        
    items.present(viewStyle)
def browse():
    myChannel = Channel.mine()
    
    items = ItemList()    
    items.addYoutubePlaylist(   myChannel.likesPL,         playlistsVisual)
    items.addYoutubePlaylist(   myChannel.favoritesPL,     playlistsVisual)
    items.addYoutubePlaylist(   myChannel.watchHistoryPL,  playlistsVisual)
    items.addYoutubePlaylist(   myChannel.watchLaterPL,    playlistsVisual)
    
    

    items.present(ViewStyle.FILES)
def browse():    
    categories = categoryList.fetch()    
    items = ItemList()
        
    for category in categories:
        items.addYoutubeCategory(category, categoriesVisual)
        
        
    items.present(viewStyle)
예제 #13
0
def search(searchType=None, searchFile=None, pageNum=1):
    if searchFile:
        search = fromCacheFile(searchFile)

    else:
        heading = keyboardHeading[searchType]
        keyboard.show(heading)

        if not keyboard.gotInput():
            return

        query = keyboard.text()
        search = Search(query, searchType)

    if search.searchType != SearchType.BOTH:
        channelsVisual.preTitle = None
        playlistsVisual.preTitle = None

    items = ItemList()
    results = search.results

    for result in results.updatedPageItems(pageNum):
        if result.isChannel():
            channel = result
            items.addYoutubeChannel(channel, channelsVisual)

        else:
            playlist = result
            items.addYoutubePlaylist(playlist, playlistsVisual)

    if results.hasPage(pageNum + 1):
        items.addCustomFolder(
            router.searchYoutubedUrl(searchFile=search.cacheFile,
                                     pageNum=pageNum + 1),
            nextPageVisual(pageNum + 1))

    items.present(viewStyle)
예제 #14
0
def search(searchType=None, searchFile=None, pageNum=1):
    if searchFile:
        search = fromCacheFile(searchFile)
        
    else:    
        heading = keyboardHeading[searchType]
        keyboard.show(heading)
    
        if not keyboard.gotInput():
            return
        
        query = keyboard.text()
        search = Search(query, searchType)
    
        
    
    
    
    if search.searchType != SearchType.BOTH:
        channelsVisual.preTitle = None
        playlistsVisual.preTitle = None
        
    items = ItemList()
    results = search.results
        
    for result in results.updatedPageItems(pageNum):
        if result.isChannel():
            channel = result
            items.addYoutubeChannel(channel, channelsVisual)
            
        else:
            playlist = result
            items.addYoutubePlaylist(playlist, playlistsVisual)
        
    
    
    if results.hasPage(pageNum+1):
        items.addCustomFolder(router.searchYoutubedUrl(searchFile=search.cacheFile, pageNum=pageNum+1), nextPageVisual(pageNum+1))
        
        
    items.present(viewStyle)
def browse(channelFile, pageNum):
    channel = Channel.fromCacheFile(channelFile)
    
    items = ItemList()
    playlists = channel.playlists
    
    for playlist in playlists.updatedPageItems(pageNum):
        items.addYoutubePlaylist(playlist, playlistsVisual)
        
    
    if playlists.hasPage(pageNum+1):
        items.addYoutubeChannelPlaylists(channel, nextPageVisual, pageNum+1)
        
    items.present(viewStyle)
def browse(pageNum=1):
    if not login.hasCredentials():
        import sign_in_out_youtube
        if not sign_in_out_youtube.signIn():
            return

    subscriptions = Subscriptions.load()

    items = ItemList()
    channels = subscriptions.channels

    for channel in channels.updatedPageItems(pageNum):
        items.addYoutubeChannel(channel, channelsVisual)

    if channels.hasPage(pageNum + 1):
        items.addCustomFolder(
            router.browseYoutubeSubscriptionsUrl(pageNum + 1),
            nextPageVisual(pageNum + 1))

    items.present(viewStyle)
예제 #17
0
def browse(folder):
    items = ItemList()    
    files, subfolders = folder.listFolder()
    
    
    for subfolder in subfolders:
        if subfolder.name != "_images":
            items.addFolder(subfolder, foldersVisual)
            

    for collectionFile in files:
        collection = Collection.fromFile(collectionFile, loadSources=False)
        items.addCollection(collection, collectionsVisual, deleteContext=True)
        
        
        
    items.present(viewStyle)
def browse(pageNum=1):
    if not login.hasCredentials():
        import sign_in_out_youtube
        if not sign_in_out_youtube.signIn():
            return
    
    
    subscriptions = Subscriptions.load()
    
    items = ItemList()
    channels = subscriptions.channels
    
    for channel in channels.updatedPageItems(pageNum):
        items.addYoutubeChannel(channel, channelsVisual)
        
    if channels.hasPage(pageNum+1):
        items.addCustomFolder(router.browseYoutubeSubscriptionsUrl(pageNum+1), nextPageVisual(pageNum+1))
        
    items.present(viewStyle)
예제 #19
0
def browse(sourceId, collectionFile):
    collection = loader.load(collectionFile)    
    source = collection.getSource(sourceId)
    source.updateUnlimitedVideos()
    collection.dump()                   ###temp solution, should happen automatically when
                                        ###when calling updateUnlimitedVideos()
    items = ItemList()
    
    
    if xbmcaddon.Addon().getSetting('video_behaviour') == 'Play Video Only':
        for video in source.unlimitedVideos():            
            items.addVideo(video, videosVisual)
        
    else:       #will happen even if nothing is set, aka it's the defualt
        for video in source.unlimitedVideos():            
            items.addVideo(video, videosVisual, sourceSpecial=True, sourceId=sourceId, collectionFile=collectionFile) 
    
    
    items.present(viewStyle)
예제 #20
0
def browse():
    if 'win' not in sys.platform:
        raise ValueError(
            'Only windows is supported for browsing local storage at this time'
        )

    items = ItemList()

    for drive in _getDrives():
        path = drive + ':\\'
        title = path
        thumb = None
        kodiFolder = KodiFolder.fromPath(path, title, thumb)

        items.addKodiFolder(kodiFolder, drivesVisual)

    items.present(viewStyle)
예제 #21
0
def explore(folder):
    items = ItemList()    
    files, subfolders = folder.listFolder()
    
    
    for subfolder in subfolders:
        if subfolder.name != "_images":
            items.addFolder(subfolder, foldersVisual)
            
        
      
        
    if xbmcaddon.Addon().getSetting('collection_behaviour') == 'Play All':
        shouldPlay = True
    else:                                                                   #will happen even if nothing is set, aka it's the defualt
        shouldPlay = False

    for collectionFile in files:
        items.addCollection(collectionFile, collectionsVisual, shouldPlay)
        
        
        
    items.present(viewStyle)
def browse(kodiFolderFile, rootFolder=False, estimateDates=False):
    kodiFolder = KodiFolder.fromCacheFile(kodiFolderFile)
    folders, videos, allItems = kodiFolder.updatedContents(estimateDates)

    if kodiFolder.updateFailed():
        dialog.ok(st(760), st(761), st(762))  #parse error dialog
        return

    items = ItemList(hasQeuingVideos=True)

    if kodiFolder.isEmpty():
        items.present(viewStyle)
        return

    if rootFolder:
        for folder in folders:
            if not folder.path.startswith('plugin://plugin.video.collections'):
                items.addKodiFolder(folder, foldersVisual)

    else:
        items.addAddToCollection(kodiFolder, addToCollectionVisual)

        if videos:
            items.addVideoSortKodi(st(751))
            currentSort = svl.loadCurrentSort(SourceType.FOLDER)
            selected = currentSort.selected

            if selected:
                videos.sort(selected, reverseOrder=currentSort.selectedReverse
                            )  #might cause problems in future cause
                currentSort.setSelectedAsCurrent()  #didn't make a copy
                customVcts = vsToCounts[selected]
                videosVisual.setCustomVcts(customVcts)
            else:
                currentSort.setCurrent(vsr.ORIGINAL, 0, False)

        for folder in folders:
            items.addKodiFolder(folder, foldersVisual)

        for kodiVideo in videos:
            #items.addKodiVideo(kodiVideo, videosVisual)
            items.addVideo(kodiVideo, videosVisual)

    items.present(viewStyle)
def present(collectionFile):
    collection = Collection.fromFile(collectionFile)

    currentSort = svl.loadCurrentSort()
    selected = currentSort.selected

    if selected:
        collection.createCombinedList(customSort=selected,
                                      reverse=currentSort.selectedReverse)
        currentSort.setSelectedAsCurrent()
        customVcts = vsToCounts[selected]
    else:
        collection.updateDatedSources()

        vs = collection.feedSettings.sort()
        index = vs - 1  #very scatchy use of this enum, change later if causes problems
        reverse = collection.feedSettings.reverseSort()

        currentSort.setCurrent(vs, index, reverse)
        customVcts = None

    fs = collection.feedSettings
    ts = fs.TS

    items = ItemList(not fs.playVideoOnly())

    if collection.onClick() == occ.FEED:
        items.addCollectionSources(collection)

    if fs.showSettings() and not (collection.default):
        items.addCollectionSettings(collection)

    if fs.showSort():
        items.addVideoSortCollection(collection)

    if fs.showPlayAll():
        items.addCollection(collection,
                            ts.playAllVisual(),
                            onClick=occ.PLAYALL)

    videosVisual = ts.videosVisual(customVcts)
    for video in collection.videos:
        items.addVideo(video, videosVisual, collection)

    items.present(collection.feedSettings.viewStyle())


# import xbmcgui
# import xbmc
# from src.videosource.youtube import urlResolver
# from src.videosource.youtube.YoutubeVideo import watchedDic
# from src.tools import videoResolve
#
#
#
#
#
#
#
#
#
#
# class Window(xbmcgui.WindowXML):
#     def __init__(self, *args, **kwargs):
#         xbmcgui.WindowXMLDialog.__init__( self )
#         self.lis = kwargs['lis']
#
#     def onInit(self):
#         self.listctrl = self.getControl(52)
#         self.listctrl.addItems(self.lis)
#
#     def onClick(self, controlID):
#         if (controlID == 52):
#             print '1111111111111111111111111111111'
#             li = self.listctrl.getSelectedItem()
#             videoId = li.getProperty('videoId')
#             url = urlResolver.resolve(videoId)
#             print '22222222222222222222222222222222'
#             watchedDic.videoPlayed(videoId)
#
#
#             print 'playing video'
#             xbmc.executebuiltin('XBMC.PlayMedia(%s)' %url)
#
#             print 'played video'
#
#
#
#
#
#
# def present2(collectionFile):
#     collection = Collection.fromFile(collectionFile)
#     collection.updateDatedSources()
#
#     lis = []
#     for video in collection.videos:
#         li = xbmcgui.ListItem(video.title, iconImage=video.thumb, thumbnailImage=video.thumb)
#         li.setProperty('sourceTitle', video.source.title)
#         li.setProperty('viewCount', str(video.viewCount))
#         li.setProperty('videoId', str(video.id))
#
#         lis.append(li)
#
#
#     window = Window('vloody.xml', 'C:\\Users\Vlood\\AppData\Roaming\\Kodi\\addons\\plugin.video.collections', lis=lis)
#     #list = window.getControl(51)
#     #list.additem(li)
#
#     #window.addItem(li, position=1)
#
#
#     window.doModal()
def browse():
    myChannel = Channel.mine()

    items = ItemList()
    items.addYoutubePlaylist(myChannel.likesPL, playlistsVisual)
    items.addYoutubePlaylist(myChannel.favoritesPL, playlistsVisual)
    items.addYoutubePlaylist(myChannel.watchHistoryPL, playlistsVisual)
    items.addYoutubePlaylist(myChannel.watchLaterPL, playlistsVisual)

    items.present(ViewStyle.FILES)
def browse(channelFile, pageNum):
    channel = Channel.fromCacheFile(channelFile)
    
    if channel.needsInfoUpdate(checkUploadPlaylist=True):
        channel.fetchInfo()
    
    
    items = ItemList(hasQeuingVideos=True)    
    
    if pageNum == 1:
        items.addAddToCollection(channel, addToCollectionVisual)
        items.addYoutubeChannelPlaylists(channel, playlistsVisual)
        
    items.addVideoSortYoutube(st(772))
    
    videos = channel.videos
    videoList = videos.updatedPageItems(pageNum)
    
    currentSort = svl.loadCurrentSort(SourceType.CHANNEL)
    selected = currentSort.selected
    
    if selected:
        videoList.sort(selected, reverseOrder=currentSort.selectedReverse)   #might cause problems in future cause
        currentSort.setSelectedAsCurrent()                                               #didn't make a copy
        customVcts = vsToCounts[selected]
        videosVisual.setCustomVcts(customVcts)                
    else:           
        currentSort.setCurrent(vsr.DATE, 0, False)
        
    
    
    for video in videoList:
        items.addVideo(video, videosVisual)
        
    
    if videos.hasPage(pageNum+1):
        items.addYoutubeChannel(channel, nextPageVisual, pageNum+1)
        
    items.present(viewStyle)
예제 #26
0
def browse(relativePath):
    lastFolderFile = File.fromNameAndDir(LAST_FOLDER_FILE, GENERAL_CACHE_DIR)

    if relativePath.endswith('/'):
        relativePath = relativePath[:-1]

    if relativePath == USE_LAST_FOLDER_STR:
        relativePath = lastFolderFile.loadObject()

    path = MY_COLLECTIONS_DIR + relativePath
    folder = Folder.fromFullpath(path)

    items = ItemList()

    files, subfolders = folder.listFolder()

    for subfolder in subfolders:
        if subfolder.name != "_images":
            subpath = relativePath + '/' + subfolder.name
            items.addSelectableFolder(subfolder, foldersVisual, subpath)

    items.addCustomFile(NEW_COLLECTION_STR + relativePath,
                        createNewCollectionVisual)
    items.addCustomFile(NEW_FOLDER_STR + relativePath, createNewFolderVisual)

    for collectionFile in files:
        collection = Collection.fromFile(collectionFile, loadSources=False)
        items.addSelectableCollection(collection, collectionsVisual)

    lastFolderFile.dumpObject(relativePath)

    items.present(viewStyle)
예제 #27
0
def browse(kodiFolderFile, rootFolder=False, estimateDates=False):
    kodiFolder = KodiFolder.fromCacheFile(kodiFolderFile)
    folders, videos, allItems = kodiFolder.updatedContents(estimateDates)
    
    if kodiFolder.updateFailed():
        dialog.ok(  st(760), st(761), st(762)   )       #parse error dialog
        return
    
    
    
    
    items = ItemList(hasQeuingVideos=True)
        
    if kodiFolder.isEmpty():
        items.present(viewStyle)
        return
    
    
    

    
    
        
    
    if rootFolder:
        for folder in folders:
            if not folder.path.startswith('plugin://plugin.video.collections'):                
                items.addKodiFolder(folder, foldersVisual)
    
    else:
        items.addAddToCollection(kodiFolder, addToCollectionVisual)
        
        if videos:                        
            items.addVideoSortKodi(st(751))                
            currentSort = svl.loadCurrentSort(SourceType.FOLDER)
            selected = currentSort.selected
            
            if selected:
                videos.sort(selected, reverseOrder=currentSort.selectedReverse)   #might cause problems in future cause
                currentSort.setSelectedAsCurrent()                                               #didn't make a copy
                customVcts = vsToCounts[selected]
                videosVisual.setCustomVcts(customVcts)                
            else:           
                currentSort.setCurrent(vsr.ORIGINAL, 0, False)
            

        for folder in folders:
            items.addKodiFolder(folder, foldersVisual)
        
        for kodiVideo in videos:
            #items.addKodiVideo(kodiVideo, videosVisual)
            items.addVideo(kodiVideo, videosVisual)
        
    items.present(viewStyle)
예제 #28
0
def browse():
    items = ItemList()

    items.addCustomFolder(router.searchYoutubeSelectUrl(), youtubeSearchVisual)
    items.addCustomFolder(router.browseYoutubeSubscriptionsUrl(),
                          youtubeSubscriptionsVisual)
    items.addCustomFolder(router.browseYoutubeCategoriesUrl(),
                          youtubeCategoriesVisual)

    kodiFolders = (
        #path                    #title        #thumb
        #(VIDEO_ROOT_PATH,       st(710)        None,)
        (VIDEO_ADDONS_PATH, st(711), None),
        (VIDEO_LIBRARY_PATH, st(712), None),
        (VIDEO_FILES_PATH, st(713), None),
        (VIDEO_PLAYLISTS_PATH, st(714), None),
        (MUSIC_ADDONS_PATH, st(720), None),
        (MUSIC_LIBRARY_PATH, st(721), None),
        #(MUSIC_FILES_PATH,      st(722),       None),
        (MUSIC_PLAYLISTS_PATH, st(723), None),
        (PROGRAM_ADDONS_PATH, st(730), None),
        (PICTURE_ADDONS_PATH, st(731), None),
        #(PICTURE_FILES_PATH,    ??,            None)
    )

    for kodiFolder in kodiFolders:
        path, title, thumb = kodiFolder
        kodiFolder = KodiFolder.fromPath(path, title, thumb)
        items.addKodiFolder(kodiFolder, kodiFoldersVisual, root=True)

#     if 'win' in sys.platform:
#         items.addCustomFolder(router.browseLocalStorageUrl(),           localStorageVisual)

    items.present(viewStyle)
def browse(relativePath):
    lastFolderFile = File.fromNameAndDir(LAST_FOLDER_FILE, GENERAL_CACHE_DIR)
    
    
    if relativePath.endswith('/'):
        relativePath = relativePath[:-1]
        
    if relativePath == USE_LAST_FOLDER_STR:
        relativePath = lastFolderFile.loadObject()
    
    path = MY_COLLECTIONS_DIR + relativePath
    folder = Folder.fromFullpath(path) 
    
    items = ItemList()
    
    
    
    files, subfolders = folder.listFolder()
    
    for subfolder in subfolders:
        if subfolder.name != "_images":
            subpath = relativePath + '/' + subfolder.name
            items.addSelectableFolder(subfolder, foldersVisual, subpath)
            
    
    items.addCustomFile(NEW_COLLECTION_STR + relativePath, createNewCollectionVisual)
    items.addCustomFile(NEW_FOLDER_STR + relativePath, createNewFolderVisual)
            
        
    

    for collectionFile in files:
        collection = Collection.fromFile(collectionFile, loadSources=False)
        items.addSelectableCollection(collection, collectionsVisual)
        
    
    
    lastFolderFile.dumpObject(relativePath)
        
    items.present(viewStyle)
예제 #30
0
def browse(playlistFile, pageNum):
    playlist = Playlist.fromCacheFile(playlistFile)

    items = ItemList(hasQeuingVideos=True)

    if pageNum == 1:
        items.addAddToCollection(playlist, addToCollectionVisual)

    items.addVideoSortYoutube(st(781))

    videos = playlist.videos
    videoList = videos.updatedPageItems(pageNum)

    currentSort = svl.loadCurrentSort(SourceType.PLAYLIST)
    selected = currentSort.selected

    if selected:
        videoList.sort(selected, reverseOrder=currentSort.selectedReverse
                       )  #might cause problems in future cause
        currentSort.setSelectedAsCurrent()  #didn't make a copy
        customVcts = vsToCounts[selected]
        videosVisual.setCustomVcts(customVcts)
    else:
        currentSort.setCurrent(vsr.DATE, 0, False)

    for video in videos.updatedPageItems(pageNum):
        items.addVideo(video, videosVisual)

    if videos.hasPage(pageNum + 1):
        items.addYoutubePlaylist(playlist, nextPageVisual, pageNum + 1)

    items.present(viewStyle)
예제 #31
0
def browse():
    items = ItemList()
    
    items.addCustomFolder(router.searchYoutubeSelectUrl(),          youtubeSearchVisual)
    items.addCustomFolder(router.browseYoutubeSubscriptionsUrl(),   youtubeSubscriptionsVisual)
    items.addCustomFolder(router.browseYoutubeCategoriesUrl(),      youtubeCategoriesVisual)
    
    
    
    kodiFolders = (
        #path                    #title        #thumb
        #(VIDEO_ROOT_PATH,       st(710)        None,)
        (VIDEO_ADDONS_PATH,      st(711),       None),
        (VIDEO_LIBRARY_PATH,     st(712),       None),
        (VIDEO_FILES_PATH,       st(713),       None),
        (VIDEO_PLAYLISTS_PATH,   st(714),       None),
        
        (MUSIC_ADDONS_PATH,      st(720),       None),
        (MUSIC_LIBRARY_PATH,     st(721),       None),
        #(MUSIC_FILES_PATH,      st(722),       None),
        (MUSIC_PLAYLISTS_PATH,   st(723),       None),
        
        (PROGRAM_ADDONS_PATH,    st(730),       None),
        
        (PICTURE_ADDONS_PATH,    st(731),       None),
        #(PICTURE_FILES_PATH,    ??,            None)
    )
    
    for kodiFolder in kodiFolders:
        path, title, thumb = kodiFolder        
        kodiFolder = KodiFolder.fromPath(path, title, thumb)
        items.addKodiFolder(kodiFolder, kodiFoldersVisual, root=True)
        
    
#     if 'win' in sys.platform:
#         items.addCustomFolder(router.browseLocalStorageUrl(),           localStorageVisual)
    

    items.present(viewStyle)
예제 #32
0
def present(collectionFile):
    collection = Collection.fromFile(collectionFile)
      
          
    currentSort = svl.loadCurrentSort()
    selected = currentSort.selected
      
    if selected:
        collection.createCombinedList(customSort=selected, reverse=currentSort.selectedReverse)
        currentSort.setSelectedAsCurrent()
        customVcts = vsToCounts[selected]
    else:
        collection.updateDatedSources()
                
        vs = collection.feedSettings.sort()
        index = vs - 1  #very scatchy use of this enum, change later if causes problems
        reverse = collection.feedSettings.reverseSort()
          
        currentSort.setCurrent(vs, index, reverse)
        customVcts = None
      
      
    fs = collection.feedSettings
    ts = fs.TS
      
    items = ItemList(not fs.playVideoOnly())
      
      
    if collection.onClick() == occ.FEED:
        items.addCollectionSources(collection)
      
    if fs.showSettings() and not (collection.default):
        items.addCollectionSettings(collection)
          
    if fs.showSort():
        items.addVideoSortCollection(collection)
      
    if fs.showPlayAll():    
        items.addCollection(collection, ts.playAllVisual(), onClick=occ.PLAYALL)
          
  
      
      
    videosVisual = ts.videosVisual(customVcts)
    for video in collection.videos:
        items.addVideo(video, videosVisual, collection)            
      
      
    items.present(collection.feedSettings.viewStyle())
    
    
    
    
    
    
    
    
    
    
    
# import xbmcgui
# import xbmc
# from src.videosource.youtube import urlResolver
# from src.videosource.youtube.YoutubeVideo import watchedDic
# from src.tools import videoResolve
# 
# 
# 
# 
#     
#     
# 
# 
# 
# 
# class Window(xbmcgui.WindowXML):
#     def __init__(self, *args, **kwargs):
#         xbmcgui.WindowXMLDialog.__init__( self )
#         self.lis = kwargs['lis']
#     
#     def onInit(self):
#         self.listctrl = self.getControl(52)
#         self.listctrl.addItems(self.lis)
#         
#     def onClick(self, controlID):
#         if (controlID == 52):
#             print '1111111111111111111111111111111'
#             li = self.listctrl.getSelectedItem()
#             videoId = li.getProperty('videoId')
#             url = urlResolver.resolve(videoId)
#             print '22222222222222222222222222222222'
#             watchedDic.videoPlayed(videoId)
#             
#             
#             print 'playing video'
#             xbmc.executebuiltin('XBMC.PlayMedia(%s)' %url)
#             
#             print 'played video'
# 
# 
# 
# 
# 
# 
# def present2(collectionFile):
#     collection = Collection.fromFile(collectionFile)
#     collection.updateDatedSources()
#     
#     lis = []
#     for video in collection.videos:
#         li = xbmcgui.ListItem(video.title, iconImage=video.thumb, thumbnailImage=video.thumb)
#         li.setProperty('sourceTitle', video.source.title)
#         li.setProperty('viewCount', str(video.viewCount))
#         li.setProperty('videoId', str(video.id))
#         
#         lis.append(li)
#         
#     
#     window = Window('vloody.xml', 'C:\\Users\Vlood\\AppData\Roaming\\Kodi\\addons\\plugin.video.collections', lis=lis)
#     #list = window.getControl(51)
#     #list.additem(li)
#     
#     #window.addItem(li, position=1)
#     
#     
#     window.doModal()