Example #1
0
    def getFolderPackage(self, entry, folderName=''):

        resourceID = 0
        title = ''
        for r in re.finditer('\"name\"\:\"([^\"]+)\"', entry, re.DOTALL):
            title = r.group(1)
            try:
                title = title.decode('unicode-escape')
                title = title.encode('utf-8')
            except:
                pass
            break
        for r in re.finditer('resid\=([^\"]+)\"', entry, re.DOTALL):
            resourceID = r.group(1)
            break

        media = package.package(None, folder.folder(resourceID, title))
        return media
    def getFolderPackage(self, entry, folderName=''):

                resourceID = 0
                title = ''
                for r in re.finditer('\"name\"\:\"([^\"]+)\"' ,
                             entry, re.DOTALL):
                  title = r.group(1)
                  try:
                            title = title.decode('unicode-escape')
                            title = title.encode('utf-8')
                  except:
                            pass
                  break
                for r in re.finditer('resid\=([^\"]+)\"' ,
                             entry, re.DOTALL):
                  resourceID = r.group(1)
                  break

                media = package.package(None,folder.folder(resourceID,title))
                return media
Example #3
0
 def getDownloadURL(self, docid):
     (media,pack) = self.getPlaybackCall(package.package(file.file(docid, docid, docid, self.VIDEO, '', ''),folder.folder('','')))
     return media[0].url
Example #4
0
#                    resName,resID = q.groups()
                for q in re.finditer('\"(name)\"\:\"([^\"]+)\",\"orderedFriendlyName\"' ,entry2, re.DOTALL):
                    titleID,title = q.groups()

                baseURL = ''
                for q in re.finditer('\"(thumbnailSet)\"\:\{\"baseUrl\"\:\"([^\"]+)\"' ,entry2, re.DOTALL):
                    baseID,baseURL = q.groups()
                    baseURL = re.sub('\\\\', '', baseURL)

                thumbnailURL = ''
                for q in re.finditer('\"(name)\"\:\"height128\"\,\"streamVersion\"\:\d+\,\"url\"\:\"([^\"]+)\"' ,entry2, re.DOTALL):
                    thumbnailID,thumbnailURL = q.groups()
                    thumbnailURL = re.sub('\\\\', '', thumbnailURL)

                if thumbnailURL != '':
                    media = package.package(file.file(resID, title+ extensionValue, title+ extensionValue, self.VIDEO, '', baseURL+thumbnailURL+ '|' + urllib.urlencode({ 'User-Agent' : self.user_agent, 'Cookie' : cookieString })),folder.folder(folderName,folderName))
                else:
                    media = package.package(file.file(resID, title+ extensionValue, title+ extensionValue, self.VIDEO, '', ''),folder.folder(folderName,folderName))
                media.setMediaURL(mediaurl.mediaurl(downloadURL, '','',''))
                mediaFiles.append(media)

            # photos
            for s in re.finditer('\"mimeType\"\:\"image.*?\"userRole\"\:0' ,entry, re.DOTALL):
                processed = 1
                entry2 = s.group()
                for q in re.finditer('\"(download)\"\:\"([^\"]+)\",' ,entry2, re.DOTALL):
                    downloadID,downloadURL = q.groups()
                    downloadURL = re.sub('\\\\', '', downloadURL)
                    downloadURL = re.sub('\%20', '+', downloadURL)
#                for q in re.finditer('\&(resid)\=([^\&]+)\&' ,entry2, re.DOTALL):
#                    resName,resID = q.groups()
Example #5
0
    def getMediaPackage(self, entry, folderName='', contentType=2):

        resourceID = 0
        resourceType = ''
        title = ''
        fileSize = 0
        url = ''
        for r in re.finditer('\"mimeType\"\:\"([^\"]+)\"', entry, re.DOTALL):
            resourceType = r.group(1)
            break
        for r in re.finditer('\"name\"\:\"([^\"]+)\"', entry, re.DOTALL):
            title = r.group(1)
            try:
                title = title.decode('unicode-escape')
                title = title.encode('utf-8')
            except:
                pass
            break
        for r in re.finditer('\"size\"\:\s*(\d+)', entry, re.DOTALL):
            fileSize = r.group(1)
            break
        for r in re.finditer('\"@content.downloadUrl\"\:\"([^\"]+)\"', entry,
                             re.DOTALL):
            url = r.group(1)
            break
        for r in re.finditer('resid\=([^\"]+)\"', entry, re.DOTALL):
            resourceID = r.group(1)
            break

        # entry is a video
        if ('video' in resourceType and contentType in (0, 1, 2, 4, 7)):
            thumbnail = 'https://api.onedrive.com/v1.0/drive/items/' + str(
                resourceID) + '/thumbnails/0/small/content'
            #                    thumbnail = self.cache.getThumbnail(self, thumbnail,resourceID)
            mediaFile = file.file(resourceID,
                                  title,
                                  title,
                                  self.MEDIA_TYPE_VIDEO,
                                  '',
                                  thumbnail,
                                  size=fileSize)

            media = package.package(mediaFile, folder.folder(folderName, ''))
            media.setMediaURL(mediaurl.mediaurl(url, 'original', 0, 9999))
            return media

        # entry is a music file
        elif ('audio' in resourceType and contentType in (1, 2, 3, 4, 6, 7)):
            thumbnail = 'https://api.onedrive.com/v1.0/drive/items/' + str(
                resourceID) + '/thumbnails/0/small/content'
            #                    thumbnail = self.cache.getThumbnail(self, thumbnail,resourceID)

            mediaFile = file.file(resourceID,
                                  title,
                                  title,
                                  self.MEDIA_TYPE_MUSIC,
                                  '',
                                  thumbnail,
                                  size=fileSize)
            media = package.package(mediaFile, folder.folder(folderName, ''))
            media.setMediaURL(mediaurl.mediaurl(url, 'original', 0, 9999))
            return media

        # entry is a photo
        elif ('image' in resourceType and contentType in (2, 4, 5, 6, 7)):
            thumbnail = 'https://api.onedrive.com/v1.0/drive/items/' + str(
                resourceID) + '/thumbnails/0/small/content'
            #                    thumbnail = self.cache.getThumbnail(self, thumbnail,resourceID)
            mediaFile = file.file(resourceID,
                                  title,
                                  title,
                                  self.MEDIA_TYPE_PICTURE,
                                  '',
                                  thumbnail,
                                  size=fileSize)

            media = package.package(mediaFile, folder.folder(folderName, ''))
            media.setMediaURL(mediaurl.mediaurl(url, '', '', ''))
            return media

        # entry is unknown
        elif ('application' in resourceType):
            mediaFile = file.file(resourceID,
                                  title,
                                  title,
                                  self.MEDIA_TYPE_VIDEO,
                                  '',
                                  '',
                                  size=fileSize)

            media = package.package(mediaFile, folder.folder(folderName, ''))
            media.setMediaURL(mediaurl.mediaurl(url, 'original', 0, 9999))
            return media

        # all files (for saving to encfs)
        elif (contentType == 8):
            mediaFile = file.file(resourceID,
                                  title,
                                  title,
                                  self.MEDIA_TYPE_VIDEO,
                                  '',
                                  '',
                                  size=fileSize)

            media = package.package(mediaFile, folder.folder(folderName, ''))
            media.setMediaURL(mediaurl.mediaurl(url, '', '', ''))
            return media
Example #6
0
                    #fileName = unicode(fileName, "unicode-escape")
                    # Undo any urlencoding before displaying the files (should also make the folders accessible)
                    #fileName = urllib.unquote(fileName)

                    if fileType == 'video':
                        fileType = self.MEDIA_TYPE_VIDEO
                    elif fileType == 'audio':
                        fileType = self.MEDIA_TYPE_MUSIC
                    elif fileType == 'image':
                        fileType = self.MEDIA_TYPE_PICTURE

                    if contentType == 'dir':
                        mediaFiles.append(
                            package.package(
                                0,
                                folder.folder(folderName + '/' + fileName,
                                              fileName)))
                    else:
                        thumbnail = self.protocol + self.domain + '/index.php/core/preview.png?file=' + folderName + '/' + fileName + '&x=50&y=50' + '|' + self.getHeadersEncoded(
                        )

                        mediaFiles.append(
                            package.package(
                                file.file(fileName, fileName, fileName,
                                          fileType, '', thumbnail),
                                folder.folder(folderName, folderName)))

            return mediaFiles
        else:
            for r in re.finditer('\[\{.*?\}\]', response_data, re.DOTALL):
                entry = r.group()
Example #7
0
                    except:
                        break

                    if count == max_count:
                        break
                    count = count + 1

    elif instanceName != '':

            oc = owncloud.owncloud(PLUGIN_URL,addon,instanceName, user_agent)



    mediaFile = file.file(filename, title, '', 0, '','')
    mediaFolder = folder.folder(directory,directory)
    url = oc.getPlaybackCall(cacheType,package.package(mediaFile,mediaFolder ))

    item = xbmcgui.ListItem(path=url)
    item.setInfo( type="Video", infoLabels={ "Title": filename , "Plot" : filename } )
    xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)

#if mode == 'options' or mode == 'buildstrm' or mode == 'clearauth':
#    addMenu(PLUGIN_URL+'?mode=clearauth','<<'+addon.getLocalizedString(30018)+'>>')
#    addMenu(PLUGIN_URL+'?mode=buildstrm','<<'+addon.getLocalizedString(30025)+'>>')



xbmcplugin.endOfDirectory(plugin_handle)

Example #8
0
            except:
                break

            if count == max_count:
                break
            count = count + 1

    elif instanceName != '':

        oc = owncloud.owncloud(PLUGIN_URL, addon, instanceName, user_agent)

    mediaFile = file.file(filename, title, '', 0, '', '')
    mediaFolder = folder.folder(directory, directory)
    url = oc.getPlaybackCall(cacheType,
                             package.package(mediaFile, mediaFolder))

    item = xbmcgui.ListItem(path=url)
    item.setInfo(type="Video",
                 infoLabels={
                     "Title": filename,
                     "Plot": filename
                 })
    xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)

#if mode == 'options' or mode == 'buildstrm' or mode == 'clearauth':
#    addMenu(PLUGIN_URL+'?mode=clearauth','<<'+addon.getLocalizedString(30018)+'>>')
#    addMenu(PLUGIN_URL+'?mode=buildstrm','<<'+addon.getLocalizedString(30025)+'>>')

xbmcplugin.endOfDirectory(plugin_handle)
            service.downloadPicture(url, str(encfs_source) + encryptedPath +str(title))

        item = xbmcgui.ListItem(path=encfs_target + dencryptedPath)
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)

        playbackMedia = False

    else:
        playbackMedia = True

    # file ID provided
    #if we don't have the docid, search for the video for playback
    if (playbackMedia and filename != '' and mode == 'audio'):
        mediaFile = file.file(filename, title, '', service.MEDIA_TYPE_MUSIC, '','')
        mediaFolder = folder.folder(folderID,'')
        (mediaURLs,package) = service.getPlaybackCall(package=package.package(mediaFile,mediaFolder))
    elif (playbackMedia and filename != ''):
        mediaFile = file.file(filename, title, '', 0, '','')
        mediaFolder = folder.folder(folderID,'')
        (mediaURLs,package) = service.getPlaybackCall(package=package.package(mediaFile,mediaFolder))
    # search
    elif playbackMedia and mode == 'search':

            if title == '':

                try:
                    dialog = xbmcgui.Dialog()
                    title = dialog.input(addon.getLocalizedString(30110), type=xbmcgui.INPUT_ALPHANUM)
                except:
                    xbmcgui.Dialog().ok(addon.getLocalizedString(30000), addon.getLocalizedString(30100))
                    title = 'test'
Example #10
0
 def getDownloadURL(self, docid):
     (media, pack) = self.getPlaybackCall(
         package.package(file.file(docid, docid, docid, self.VIDEO, '', ''),
                         folder.folder('', '')))
     return media[0].url
Example #11
0
                    baseID, baseURL = q.groups()
                    baseURL = re.sub('\\\\', '', baseURL)

                thumbnailURL = ''
                for q in re.finditer(
                        '\"(name)\"\:\"height128\"\,\"streamVersion\"\:\d+\,\"url\"\:\"([^\"]+)\"',
                        entry2, re.DOTALL):
                    thumbnailID, thumbnailURL = q.groups()
                    thumbnailURL = re.sub('\\\\', '', thumbnailURL)

                if thumbnailURL != '':
                    media = package.package(
                        file.file(
                            resID, title + extensionValue,
                            title + extensionValue, self.VIDEO, '',
                            baseURL + thumbnailURL + '|' +
                            urllib.urlencode({
                                'User-Agent': self.user_agent,
                                'Cookie': cookieString
                            })), folder.folder(folderName, folderName))
                else:
                    media = package.package(
                        file.file(resID, title + extensionValue,
                                  title + extensionValue, self.VIDEO, '', ''),
                        folder.folder(folderName, folderName))
                media.setMediaURL(mediaurl.mediaurl(downloadURL, '', '', ''))
                mediaFiles.append(media)

            # photos
            for s in re.finditer('\"mimeType\"\:\"image.*?\"userRole\"\:0',
                                 entry, re.DOTALL):
Example #12
0
                    except:
                        pass

                    # fileName = unicode(fileName, "unicode-escape")
                    # Undo any urlencoding before displaying the files (should also make the folders accessible)
                    # fileName = urllib.unquote(fileName)

                    if fileType == "video":
                        fileType = self.MEDIA_TYPE_VIDEO
                    elif fileType == "audio":
                        fileType = self.MEDIA_TYPE_MUSIC
                    elif fileType == "image":
                        fileType = self.MEDIA_TYPE_PICTURE

                    if contentType == "dir":
                        mediaFiles.append(package.package(0, folder.folder(folderName + "/" + fileName, fileName)))
                    else:
                        thumbnail = (
                            self.protocol
                            + self.domain
                            + "/index.php/core/preview.png?file="
                            + folderName
                            + "/"
                            + fileName
                            + "&x=50&y=50"
                            + "|"
                            + self.getHeadersEncoded()
                        )

                        mediaFiles.append(
                            package.package(
Example #13
0
                            pass

                    #fileName = unicode(fileName, "unicode-escape")
                    # Undo any urlencoding before displaying the files (should also make the folders accessible)
                    #fileName = urllib.unquote(fileName)

                    if fileType == 'video':
                        fileType = self.MEDIA_TYPE_VIDEO
                    elif fileType == 'audio':
                        fileType = self.MEDIA_TYPE_MUSIC
                    elif fileType == 'image':
                        fileType = self.MEDIA_TYPE_PICTURE


                    if contentType == 'dir':
                        mediaFiles.append(package.package(0,folder.folder(folderName+'/'+fileName,fileName)) )
                    else:
                        thumbnail = self.protocol + self.domain +'/index.php/core/preview.png?file='+folderName+ '/'+fileName + '&x=50&y=50'+'|' + self.getHeadersEncoded()

                        mediaFiles.append(package.package(file.file(fileName, fileName, fileName, fileType, '', thumbnail),folder.folder(folderName,folderName)) )

            return mediaFiles
        else:
            for r in re.finditer('\[\{.*?\}\]' ,response_data, re.DOTALL):
                entry = r.group()

                for s in re.finditer('\{.*?\}' ,entry, re.DOTALL):
                    item = s.group()

                    fileID = ''
                    fileName = ''
    def getMediaPackage(self, entry, folderName='',contentType=2):

                resourceID = 0
                resourceType = ''
                title = ''
                fileSize = 0
                url = ''
                for r in re.finditer('\"mimeType\"\:\"([^\"]+)\"' ,
                             entry, re.DOTALL):
                  resourceType = r.group(1)
                  break
                for r in re.finditer('\"name\"\:\"([^\"]+)\"' ,
                             entry, re.DOTALL):
                  title = r.group(1)
                  try:
                            title = title.decode('unicode-escape')
                            title = title.encode('utf-8')
                  except:
                            pass
                  break
                for r in re.finditer('\"size\"\:\s*(\d+)' ,
                             entry, re.DOTALL):
                  fileSize = r.group(1)
                  break
                for r in re.finditer('\"@content.downloadUrl\"\:\"([^\"]+)\"' ,
                             entry, re.DOTALL):
                  url = r.group(1)
                  break
                for r in re.finditer('resid\=([^\"]+)\"' ,
                             entry, re.DOTALL):
                  resourceID = r.group(1)
                  break

                # entry is a video
                if ('video' in resourceType and contentType in (0,1,2,4,7)):
                    thumbnail = 'https://api.onedrive.com/v1.0/drive/items/'+str(resourceID)+'/thumbnails/0/small/content'
#                    thumbnail = self.cache.getThumbnail(self, thumbnail,resourceID)
                    mediaFile = file.file(resourceID, title, title, self.MEDIA_TYPE_VIDEO, '', thumbnail, size=fileSize)

                    media = package.package(mediaFile,folder.folder(folderName,''))
                    media.setMediaURL(mediaurl.mediaurl(url, 'original', 0, 9999))
                    return media

                # entry is a music file
                elif ('audio' in resourceType and contentType in (1,2,3,4,6,7)):
                    thumbnail = 'https://api.onedrive.com/v1.0/drive/items/'+str(resourceID)+'/thumbnails/0/small/content'
#                    thumbnail = self.cache.getThumbnail(self, thumbnail,resourceID)

                    mediaFile = file.file(resourceID, title, title, self.MEDIA_TYPE_MUSIC, '', thumbnail, size=fileSize)
                    media = package.package(mediaFile,folder.folder(folderName,''))
                    media.setMediaURL(mediaurl.mediaurl(url, 'original', 0, 9999))
                    return media

                # entry is a photo
                elif ('image' in resourceType and contentType in (2,4,5,6,7)):
                    thumbnail = 'https://api.onedrive.com/v1.0/drive/items/'+str(resourceID)+'/thumbnails/0/small/content'
#                    thumbnail = self.cache.getThumbnail(self, thumbnail,resourceID)
                    mediaFile = file.file(resourceID, title, title, self.MEDIA_TYPE_PICTURE, '', thumbnail, size=fileSize)

                    media = package.package(mediaFile,folder.folder(folderName,''))
                    media.setMediaURL(mediaurl.mediaurl(url, '','',''))
                    return media

                # entry is unknown
                elif ('application' in resourceType):
                    mediaFile = file.file(resourceID, title, title, self.MEDIA_TYPE_VIDEO, '', '', size=fileSize)

                    media = package.package(mediaFile,folder.folder(folderName,''))
                    media.setMediaURL(mediaurl.mediaurl(url, 'original', 0, 9999))
                    return media

                # all files (for saving to encfs)
                elif (contentType == 8):
                    mediaFile = file.file(resourceID, title, title, self.MEDIA_TYPE_VIDEO, '', '', size=fileSize)

                    media = package.package(mediaFile,folder.folder(folderName,''))
                    media.setMediaURL(mediaurl.mediaurl(url, '','',''))
                    return media