Beispiel #1
0
 def resolveFile(self, in_relativeFilePath, in_parentFilePathOrNone=None):
     if in_parentFilePathOrNone:
         newPath = os.path.join(self.cwd,
                                os.path.dirname(in_parentFilePathOrNone),
                                in_relativeFilePath)
         if os.path.isfile(newPath):
             return filewrapper.FileWrapper(in_relativeFilePath, newPath)
     for item in self.inputDirArray:
         newPath = os.path.join(self.cwd, item, in_relativeFilePath)
         if os.path.isfile(newPath):
             return filewrapper.FileWrapper(in_relativeFilePath, newPath)
     print("ERROR: could not resolve file path:" + in_relativeFilePath)
     print("cwd:" + self.cwd)
     for item in self.inputDirArray:
         print("  " + item)
Beispiel #2
0
 def get_video_file(self, info_hash):
     for torrent_handle in self.torrent_handles:
         if str(torrent_handle.info_hash()) == info_hash:
             video_file = self._get_video_file_from_torrent(torrent_handle)
             if video_file:
                 if torrent_handle.status().paused:
                     torrent_handle.resume()
                 return filewrapper.FileWrapper(self.bus, torrent_handle, video_file)
             else:
                 return None
     raise RuntimeError
Beispiel #3
0
    def download(self):
        video_file = self._get_first_video_file(
            cherrypy.engine.nzbdownloader.downloader.extractor.files)
        if not video_file:
            return 'Not ready!'

        return serve_fileobj(filewrapper.FileWrapper(video_file['path'],
                                                     video_file['size']),
                             content_type='application/x-download',
                             content_length=video_file['size'],
                             disposition='attachment',
                             name=os.path.basename(video_file['path']))
Beispiel #4
0
    def video(self):
        video_file = self._get_first_video_file(
            cherrypy.engine.nzbdownloader.downloader.extractor.files)
        if not video_file:
            return 'Not ready!'

        content_type = mimetypes.types_map.get(
            os.path.splitext(video_file['path']), None)

        if not content_type:
            if video_file['path'].endswith('.mkv'):
                content_type = 'video/x-matroska'
            elif video_file['path'].endswith('.mp4'):
                content_type = 'video/mp4'

        return serve_fileobj(filewrapper.FileWrapper(video_file['path'],
                                                     video_file['size']),
                             content_type=content_type,
                             content_length=video_file['size'],
                             name=os.path.basename(video_file['path']))