Ejemplo n.º 1
0
from src.tools.enum import enum
import pyxbmct.addonwindow as pyxbmct
from src.tools.dialog import dialog


EnumMode = enum(SELECT=0, ROTATE=1)


class EnumButton(object):
    def __init__(self, label, values, current, default, changeCallback=None, saveCallback=None, customLabels=None, mode=EnumMode.SELECT, returnValue=False, alignment=pyxbmct.ALIGN_CENTER):
        
        self.label = label
        self.values = values
        self.customLabels = customLabels
        self.mode = mode
        self.returnValue = returnValue
        self.changeCallback = changeCallback
        self.saveCallback = saveCallback

        
        
        self.currentValue = current
        self.defaultValue = default        
        self.currentIndex = None        
        self.defaultIndex = None
        
                
        self.assignedValue = False
        
        if saveCallback is None:
            self.onSave = None
Ejemplo n.º 2
0
import service
import Channel
from Pages import Pages, ItemType, TimeUnit
from src.file import File
from src.paths.root import YOUTUBE_CACHE_DIR
from src.tools.enum import enum
import settings as s


SubscriptionSorting = enum(ALPHABETICAL='alphabetical', RELEVANCE='relevance', UNREAD='unread')






CACHE_FILE = 'subscriptions.sub' 


loaded = None


class Subscriptions:
    def __init__(self, cacheFile):                
        self.channels = Pages(self._serviceRequest, self._responseProcess, ItemType.VSOURCE, 'subscription channels', s.subscriptionChannelsCacheTime, TimeUnit.DAYS, self)
        
        
        self.cacheFile = cacheFile
        self.order = s.subscriptionSorting()
        
        global loaded
Ejemplo n.º 3
0
import service
import Playlist
import Channel
from settings import regionCode
from src.tools.enum import enum
from Pages import Pages, ItemType, TimeUnit
import settings as s
from src.file import File
from src.paths.root import SEARCH_CACHE_DIR
import uuid



SearchType = enum(CHANNEL='channel', PLAYLIST='playlist', BOTH='channel,playlist')


class Search(object):
    def __init__(self, query, searchType):
        self.query = query
        self.searchType = searchType
        
        self.results = Pages(self._serviceRequest, self._responseProcess, ItemType.VSOURCE, '%s search results' %searchType, s.searchesCacheTime, TimeUnit.MINUTES, self)
        
        cacheFileName = str(uuid.uuid4()) + '.srch'
        self.cacheFile = File.fromNameAndDir(cacheFileName, SEARCH_CACHE_DIR)
        
        
        
    def cache(self, fromPages=False):
        if fromPages:
            self.cacheFile.dumpObject(self)
Ejemplo n.º 4
0
from datetime import datetime, timedelta
from src.tools import fixedDatetime
from src.tools import pytz
from src.tools.enum import enum


DateType = enum ( FIRST_AIRED=1, PREMIERED=2, DATE_ADDED=3, YEAR=4, ESTIMATED=5)




def processAll(item, folderRecord=None):
        path                =       item['file']
    
        title               =       processTitle(item)        
        description         =       _getValue(item, 'plot')
        thumb               =       _getValue(item, 'thumbnail')
        
        

        date, dateType  =       processDate(item, path, folderRecord)
        duration        =       processDuration(item)
        #playCount      =       _getValue(item, 'playcount')
        #lastPlayed     =       _processLastPlayed(item)
        
        rating          =       item.get('rating')      #this returns 0 if empty, can maybe set it as None 
                                                        #when this happens instead of storing the 0
        
        return path, title, description, thumb, date, dateType, duration, rating

Ejemplo n.º 5
0
import TextSettings
from src.tools.enum import enum

Location = enum(LEFT_ALIGNED=1, LEFT=2, MIDDLE=3, RIGHT=4)

class FullTextSettings(object):
    def __init__(self, titleTS, sourceTS=None, countTS=None, count2TS=None, countLocation=None):                
        self.titleTS = titleTS
        self.sourceTS = sourceTS
        self.countTS = countTS
        self.count2TS = count2TS
        self.countLocation = countLocation
        
        
        
    
            
    def titleText(self, text):
        return self.titleTS.apply(text)
    
    
    def sourceText(self, text):
        if self.sourceTS is None:
            raise ValueError('This title has no source text')
                
        return self.sourceTS.apply(text + ':')
    
    
    def countText(self, number, ts):
        if ts is None:
            raise ValueError('This title has no count text')
Ejemplo n.º 6
0
from src.tools import DataDictionary
from src.file import File
import simplejson as json
from strings import jsonRpcDir
import xbmc
from src.tools.enum import enum
import uuid
from datetime import datetime
import settings as s
import threading
from src import router

PATH_DIC_FILE = '__pathes.dic'
MediaType = enum(VIDEO='video',
                 MUSIC='music',
                 PICTURES='pictures',
                 FILES='files',
                 PROGRAMS='programs')

foldersLoaded = {}
pathDic = DataDictionary.load(PATH_DIC_FILE, KODI_FOLDER_CACHE_DIR)


class KodiFolder(VideoSource):
    def __init__(self,
                 path,
                 title,
                 thumb,
                 description=None,
                 date=None,
                 dateType=None,
from settings import globalCollection
from src import router
from src.tools.addonSettings import string as st
from src.tools.enum import enum

OnSourceClick = enum(BROWSE=1, PLAYALL=2, BROWSE_ORIGIN=3)

gfs = None
gss = None


class CollectionSource(object):
    def __init__(self,
                 index,
                 collection,
                 videoSource,
                 onClick=None,
                 useInFeed=True,
                 limit=None,
                 customTitle=None,
                 customThumb=None):
        self.id = videoSource.id
        self.index = index
        self.collection = collection
        self.videoSource = videoSource

        self._onClick = onClick
        self.useInFeed = useInFeed
        self._limit = limit
        self.customTitle = customTitle
        self.customThumb = customThumb
Ejemplo n.º 8
0
from settings import globalCollection
from csource.KodiCollectionSource import KodiCollectionSource
from csource.YoutubeCollectionSource import YoutubeCollectionSource
from src.tools.enum import enum
from src import router
from src.tools.addonSettings import string as st
from src.videosource.VideoList import VideoList
from src.videosource.kodi.FolderVideo import ParseMethod




loaded = {}


OnCollectionClick = enum(FEED=1, SOURCES=2, SOURCES_ONLY=3, PLAYALL=4)

GLOBAL_COLLECTION_FILE = 'globalCollection.xml'

D_TITLE = st(400)
D_THUMB = 'special://home/addons/plugin.video.collections/icon.png'
D_DEFAULT = False
D_ONCLICK = OnCollectionClick.FEED  #for global. for individual collection it's None


gc = None
class Collection(object):            
    def __init__(self, title, thumb, feedSettings, sourcesSettings, folderSettings, collectionFile, default=False, onClick=None):        
        self.title = title
        self.thumb = thumb
        self.default = default
import TextSettings
from src.tools.enum import enum

Location = enum(LEFT_ALIGNED=1, LEFT=2, MIDDLE=3, RIGHT=4)


class FullTextSettings(object):
    def __init__(self,
                 titleTS,
                 sourceTS=None,
                 countTS=None,
                 count2TS=None,
                 countLocation=None):
        self.titleTS = titleTS
        self.sourceTS = sourceTS
        self.countTS = countTS
        self.count2TS = count2TS
        self.countLocation = countLocation

    def titleText(self, text):
        return self.titleTS.apply(text)

    def sourceText(self, text):
        if self.sourceTS is None:
            raise ValueError('This title has no source text')

        return self.sourceTS.apply(text + ':')

    def countText(self, number, ts):
        if ts is None:
            raise ValueError('This title has no count text')
Ejemplo n.º 10
0
from src.tools.enum import enum

ViewStyle = enum(FILES='files', SONGS='songs', ARTISTS='artists', ALBUMS='albums', MOVIES='movies', 
                 TVSHOWS='tvshows', EPISODES='episodes', MUSICVIDEOS='musicvideos')
Ejemplo n.º 11
0
from src.videosource.Video import Video
from src import router
from src.tools import WatchedDic
from src.paths.root import KODI_DATA_DIR
from src.tools.enum import enum

ParseMethod = enum(NORMAL=1, FIRST_IN_FOLDER=2, FOLDERS_AS_VIDEOS=3)



FIRST_IN_FOLDER_WATCHED_DIC_FILE        = 'watched_first_in_folder.dic'
#FOLDERS_AS_VIDEOS_WATCHED_DIC_FILE      = 'watched_folders_as_videos.dic'

fifWatchedDic = WatchedDic.load(FIRST_IN_FOLDER_WATCHED_DIC_FILE, KODI_DATA_DIR)
#favWatchedDic = WatchedDic.load(FOLDERS_AS_VIDEOS_WATCHED_DIC_FILE, KODI_DATA_DIR)





class FolderVideo(Video):
    def __init__(self, sourceFolder, position, kodiFolder, parseMethod):        
        videoId     = kodiFolder.path
        
        title       = kodiFolder.title
        description = kodiFolder.description
        thumb       = kodiFolder.thumb
        
        date        = kodiFolder.date        
        duration    = kodiFolder.duration
        rating      = kodiFolder.rating        
Ejemplo n.º 12
0
from src.tools.enum import enum

ViewStyle = enum(FILES='files',
                 SONGS='songs',
                 ARTISTS='artists',
                 ALBUMS='albums',
                 MOVIES='movies',
                 TVSHOWS='tvshows',
                 EPISODES='episodes',
                 MUSICVIDEOS='musicvideos')
Ejemplo n.º 13
0
import xbmcgui
from src.tools.enum import enum
dialog = xbmcgui.Dialog()


def ok(heading, line1, line2=None, line3=None):
    return dialog.ok(heading, line1, line2, line3)
    
    
def select(heading, stringList, autoclose=0):
    return dialog.select(heading, stringList, autoclose)




BrowseType = enum (SHOW_AND_GET_DIR=0, SHOW_AND_GET_FILE=1, SHOW_AND_GET_IMAGE=2, 
                   SHOW_AND_GET_WRITEABLE_DIR=3)

def browse(browseType, heading, s_shares, mask=None, useThumbs=False, treatAsFolder=False, default=None, 
           enableMultiple=False):
    return dialog.browse(browseType, heading, s_shares, mask, useThumbs, treatAsFolder, default, enableMultiple)


# def input(heading, default=None, type=None, option=0, autoclose=None):
#     return dialog.input(heading, default, xbmcgui.INPUT_ALPHANUM, option)
    #return dialog.input(heading)
    

# def notification(heading, message, icon=None, time=None, sound=None):
#     dialog.notification(heading, message, icon=icon, time=15, sound=sound)
    
    
Ejemplo n.º 14
0
from settings import globalCollection
from src import router
from src.tools.addonSettings import string as st
from src.tools.enum import enum


OnSourceClick = enum(BROWSE=1, PLAYALL=2, BROWSE_ORIGIN=3)


gfs = None
gss = None
class CollectionSource(object):
    def __init__(self, index, collection, videoSource, onClick=None, useInFeed=True, limit=None, customTitle=None, customThumb=None):
        self.id = videoSource.id
        self.index = index
        self.collection = collection        
        self.videoSource = videoSource        
        
        self._onClick = onClick
        self.useInFeed = useInFeed
        self._limit = limit
        self.customTitle = customTitle
        self.customThumb = customThumb
        
        css = self.collection.sourcesSettings
        self.css = css
        self.csts = css.TS 
        self.cfs = self.collection.feedSettings
        self.cfds = self.collection.folderSettings
        
        
Ejemplo n.º 15
0
from src.tools.enum import enum

ThumbRes = enum (MEDIUM=0, HIGH_OR_LOWER=1, HIGH_OR_BETTER=2, HIGHEST=3)

class Thumb(object):

    def __init__(self, thumbnailDetails):
        self.default = None
        self.standard = None
        self.medium = None
        self.high = None
        self.max = None

        nonRecieved = True
        
        if 'default' in thumbnailDetails:
            self.default = thumbnailDetails['default']['url']
            nonRecieved = False
        
        if 'standard' in thumbnailDetails:
            self.standard = thumbnailDetails['standard']['url']
            nonRecieved = False
                        
        if 'medium' in thumbnailDetails:
            self.medium = thumbnailDetails['medium']['url']
            nonRecieved = False
            
        if 'high' in thumbnailDetails:
            self.high = thumbnailDetails['high']['url']
            nonRecieved = False
            
Ejemplo n.º 16
0
from datetime import datetime
from src.tools.enum import enum
from src.videosource.VideoSource import SourceType
from src.videosource.VideoList  import VideoSort
from src.videosource.youtube import batchUpdater
import service


ItemType = enum(VIDEO=0, VSOURCE=1)
TimeUnit = enum(SECONDS=0, MINUTES=1, HOURS=2, DAYS=3)

DEFAULT = 43967348623       #random hack


class Pages(object):
    def __init__(self, serviceRequest, responseProcess, itemType, contentTitle, defaultCacheTime, cacheTimeUnit, sourceObject, cacheAfterUpdates=True):
        self._serviceRequest = serviceRequest
        self._responseProcess = responseProcess
        self._itemType = itemType
        self._contentTitle = contentTitle       #for example "playlist videos" or "channel playlists"
        self._defaultCacheTime = defaultCacheTime
        self._defaultCacheTimeUnit = cacheTimeUnit
        
        self._sourceObject = sourceObject
        self._cacheAfterUpdates = cacheAfterUpdates

        self.clear()
        
    
        
    def clear(self):
Ejemplo n.º 17
0
from datetime import datetime, timedelta, MINYEAR
from src.tools import pytz
from src.tools.enum import enum

VideoSort = enum(DATE=1,
                 VIEWS=2,
                 DURATION=3,
                 POSITION=4,
                 SHUFFLE=5,
                 SOURCE_TITLE=6,
                 VIDEO_TITLE=7,
                 RATING=8,
                 LIKES=9,
                 DISLIKES=10,
                 COMMENTS=11,
                 PLAYCOUNT=12,
                 LASTPLAYED=13,
                 ORIGINAL=14)

vs = VideoSort
vsToKey = {  #reverse
    vs.DATE:
    (lambda video: video.date
     if video.date else datetime(MINYEAR, 1, 1, tzinfo=pytz.utc), True),
    vs.VIEWS: (lambda video: video.viewCount
               if video.isYoutube() else -1, True),
    vs.DURATION: (lambda video: video.duration
                  if video.duration else timedelta(-1), True),
    vs.POSITION: (lambda video: video.position, False),
    vs.SOURCE_TITLE: (lambda video: video.source.title.lower(), False),
    vs.VIDEO_TITLE: (lambda video: video.title.lower(), False),
Ejemplo n.º 18
0
from src.tools.enum import enum
from src.tools.addonSettings import string as st

SourceType = enum(  FOLDER=1,                       CHANNEL=2,                          PLAYLIST=3)
stToText   = {      SourceType.FOLDER:st(420),      SourceType.CHANNEL:st(421),         SourceType.PLAYLIST:st(422)}



 
class VideoSource(object):            
    def __init__(self, title, studioTitle, tvShowTitle, description, thumb, sourceType, sourceId):                        
        self.title = title
        self.studioTitle = studioTitle
        self.tvShowTitle = tvShowTitle        
        self.description = description
        
        self.thumb = thumb
        self.type = sourceType
        
        self.id = sourceId
        
        

        
###################
## Public Methods##
###################
    def isKodiFolder(self):
        if self.type == SourceType.FOLDER:
            return True
        
Ejemplo n.º 19
0
from src.videosource.Video import Video
from src import router
from src.tools import WatchedDic
from src.paths.root import KODI_DATA_DIR
from src.tools.enum import enum

ParseMethod = enum(NORMAL=1, FIRST_IN_FOLDER=2, FOLDERS_AS_VIDEOS=3)

FIRST_IN_FOLDER_WATCHED_DIC_FILE = 'watched_first_in_folder.dic'
#FOLDERS_AS_VIDEOS_WATCHED_DIC_FILE      = 'watched_folders_as_videos.dic'

fifWatchedDic = WatchedDic.load(FIRST_IN_FOLDER_WATCHED_DIC_FILE,
                                KODI_DATA_DIR)
#favWatchedDic = WatchedDic.load(FOLDERS_AS_VIDEOS_WATCHED_DIC_FILE, KODI_DATA_DIR)


class FolderVideo(Video):
    def __init__(self, sourceFolder, position, kodiFolder, parseMethod):
        videoId = kodiFolder.path

        title = kodiFolder.title
        description = kodiFolder.description
        thumb = kodiFolder.thumb

        date = kodiFolder.date
        duration = kodiFolder.duration
        rating = kodiFolder.rating

        if parseMethod == ParseMethod.FIRST_IN_FOLDER:
            watchedDic = fifWatchedDic
            #elif parseMethod    == ParseMethod.FOLDERS_AS_VIDEOS:   watchedDic = favWatchedDic
Ejemplo n.º 20
0
import xbmcgui
from src.tools.enum import enum

dialog = xbmcgui.Dialog()


def ok(heading, line1, line2=None, line3=None):
    return dialog.ok(heading, line1, line2, line3)


def select(heading, stringList, autoclose=0):
    return dialog.select(heading, stringList, autoclose)


BrowseType = enum(SHOW_AND_GET_DIR=0,
                  SHOW_AND_GET_FILE=1,
                  SHOW_AND_GET_IMAGE=2,
                  SHOW_AND_GET_WRITEABLE_DIR=3)


def browse(browseType,
           heading,
           s_shares,
           mask=None,
           useThumbs=False,
           treatAsFolder=False,
           default=None,
           enableMultiple=False):
    return dialog.browse(browseType, heading, s_shares, mask, useThumbs,
                         treatAsFolder, default, enableMultiple)

Ejemplo n.º 21
0
from src.tools.enum import enum
import pyxbmct.addonwindow as pyxbmct
from src.tools.dialog import dialog

EnumMode = enum(SELECT=0, ROTATE=1)


class EnumButton(object):
    def __init__(self,
                 label,
                 values,
                 current,
                 default,
                 changeCallback=None,
                 saveCallback=None,
                 customLabels=None,
                 mode=EnumMode.SELECT,
                 returnValue=False,
                 alignment=pyxbmct.ALIGN_CENTER):

        self.label = label
        self.values = values
        self.customLabels = customLabels
        self.mode = mode
        self.returnValue = returnValue
        self.changeCallback = changeCallback
        self.saveCallback = saveCallback

        self.currentValue = current
        self.defaultValue = default
        self.currentIndex = None
Ejemplo n.º 22
0
from src.paths.root import KODI_FOLDER_CACHE_DIR
from src.tools import DataDictionary
from src.file import File
import simplejson as json
from strings import jsonRpcDir
import xbmc
from src.tools.enum import enum
import uuid
from datetime import datetime
import settings as s
import threading
from src import router


PATH_DIC_FILE = '__pathes.dic'
MediaType = enum(VIDEO='video', MUSIC='music', PICTURES='pictures', FILES='files', PROGRAMS='programs')


foldersLoaded = {}
pathDic = DataDictionary.load(PATH_DIC_FILE, KODI_FOLDER_CACHE_DIR)


class KodiFolder(VideoSource):
    def __init__(self, path, title, thumb, description=None, date=None, dateType=None, duration=None, rating=None):
        studioTitle = title         #maybe original's plugin name?
        tvShowTitle = title
        
        sourceType = SourceType.FOLDER
        sourceId = path
        
        super(KodiFolder, self).__init__(title, studioTitle, tvShowTitle, description, thumb, sourceType, sourceId)
Ejemplo n.º 23
0
from src.tools.enum import enum

#VideoType = enum(PLUGIN=0, YOUTUBE=1)
OnVideoClick = enum(PLAY_ONLY=1, PLAY_QUEUE_REST=2)


class Video(object):
    def __init__(self, videoId, source, position, title, description, thumb,
                 date, duration, rating, watchedDic):
        self.id = videoId
        #self.type = videoType

        self.source = source
        self.position = position
        self.title = title
        self.description = description
        self.thumb = thumb
        self.date = date
        self.duration = duration
        self.rating = rating
        self.watchedDic = watchedDic

#     #abstract
#     def resolvedUrl(self):
#         return

#abstract

    def playUrl(self):
        return
Ejemplo n.º 24
0
from src.tools.enum import enum

#VideoType = enum(PLUGIN=0, YOUTUBE=1)
OnVideoClick = enum (PLAY_ONLY=1, PLAY_QUEUE_REST=2)




class Video(object):
    def __init__(self, videoId, source, position, title, description, thumb, date, duration, rating, watchedDic):
        self.id = videoId
        #self.type = videoType
        
        self.source = source
        self.position = position
        self.title = title
        self.description = description
        self.thumb = thumb
        self.date = date
        self.duration = duration
        self.rating = rating
        self.watchedDic = watchedDic


    
#     #abstract        
#     def resolvedUrl(self):
#         return

    #abstract
    def playUrl(self):
Ejemplo n.º 25
0
from src.tools.enum import enum

ThumbRes = enum(MEDIUM=0, HIGH_OR_LOWER=1, HIGH_OR_BETTER=2, HIGHEST=3)


class Thumb(object):
    def __init__(self, thumbnailDetails):
        self.default = None
        self.standard = None
        self.medium = None
        self.high = None
        self.max = None

        nonRecieved = True

        if 'default' in thumbnailDetails:
            self.default = thumbnailDetails['default']['url']
            nonRecieved = False

        if 'standard' in thumbnailDetails:
            self.standard = thumbnailDetails['standard']['url']
            nonRecieved = False

        if 'medium' in thumbnailDetails:
            self.medium = thumbnailDetails['medium']['url']
            nonRecieved = False

        if 'high' in thumbnailDetails:
            self.high = thumbnailDetails['high']['url']
            nonRecieved = False
Ejemplo n.º 26
0
import batchUpdater
from settings import globalCollection
from csource.KodiCollectionSource import KodiCollectionSource
from csource.YoutubeCollectionSource import YoutubeCollectionSource
from src.tools.enum import enum
from src import router
from src.tools.addonSettings import string as st
from src.videosource.VideoList import VideoList
from src.videosource.kodi.FolderVideo import ParseMethod

loaded = {}

OnCollectionClick = enum(FEED=1, SOURCES=2, SOURCES_ONLY=3, PLAYALL=4)

GLOBAL_COLLECTION_FILE = 'globalCollection.xml'

D_TITLE = st(400)
D_THUMB = 'special://home/addons/plugin.video.collections/icon.png'
D_DEFAULT = False
D_ONCLICK = OnCollectionClick.FEED  #for global. for individual collection it's None

gc = None


class Collection(object):
    def __init__(self,
                 title,
                 thumb,
                 feedSettings,
                 sourcesSettings,
                 folderSettings,