コード例 #1
0
ファイル: serie.py プロジェクト: gabri1135/4k
    def initialize(detail: tuple, _outputFolder: PathModel,
                   m3u8Path: PathModel) -> None:
        temp = _outputFolder.temp(space='').add('.%d_%d' %
                                                (detail[0] + 1, detail[1] + 1))
        if temp.exist():
            m3u8Path.remove()
            return

        temp.create()
        m3u8Path.move(temp.add(".m3u8"))

        temp.add("temp.txt").write("ffconcat version 1.0\n\n", "w")
コード例 #2
0
ファイル: downloader.py プロジェクト: gabri1135/4k
    def __init__(self, _outputFile: PathModel, _tempFolder: PathModel = None) -> None:
        if _tempFolder is None:
            _tempFolder = _outputFile.temp()
        os.chdir(_tempFolder.path)

        try:
            progress = int(re.findall("file tmp_(.*).mp4",
                                      open('temp.txt', 'r').readlines()[-3])[0])+1
        except:
            progress = 0

        key, M3U8s = M3U8.getAll(self)

        dec = Decrypt(key)

        l = len(M3U8s)
        id = Id(l, progress)

        try:
            for i in range(progress, l):
                file_name = 'tmp_%s.mp4' % id.add()
                print('Processing %d of %d' % (i+1, l))

                url = M3U8s[i].url
                url = "http" + url.removeprefix("https")

                open(file_name, 'wb').write(
                    dec.get(self.getFile(url)))

                open('temp.txt', 'a').write(
                    "file %s\nduration %s\n\n" % (file_name, M3U8s[i].duration))

        except:
            print("Errore nel download dei file\nRiprova in seguito")

        else:
            #            size = 0
            #            st = os.stat_result.
            #            free = st.f_bavail * st.f_frsize
            #            for file_name in os.listdir(tempPath):
            #                size += os.path.getsize(file_name)
            #
            #            if free >= size:
            self._concatenateAll()
#            else:
#                self._concatenateProgress(l)

            os.chdir(_tempFolder.dir)

            shutil.move("%s\\output.mp4" % _tempFolder.name, _outputFile.path)
            shutil.rmtree(_tempFolder.path)
コード例 #3
0
ファイル: film.py プロジェクト: gabri1135/4k
    def initialize(
        _outputFile: PathModel, m3u8Path: PathModel
    ) -> Tuple[Literal['created', 'continuare', 'sostituire',
                       'outPath different'], str | None, str | None]:
        _temp = _outputFile.temp()

        data = Data.create(_outputFile)
        if data == 'created':
            _temp.create()
            m3u8Path.move(_temp.add(".m3u8"))
            _temp.add("temp.txt").write("ffconcat version 1.0\n\n", "w")
            return data, None, None
        elif data == 'exist':
            if m3u8Path.read() == _temp.add(".m3u8").read():
                if m3u8Path.path != _temp.add(".m3u8").path:
                    m3u8Path.remove()
                return "continuare", None, None
            else:
                return "sostituire", None, None
        else:
            return data, _outputFile.path, m3u8Path.path
コード例 #4
0
ファイル: serie.py プロジェクト: gabri1135/4k
 def init(self, out: PathModel) -> PathModel:
     out = out.add(self.name)
     if Data.create(out):
         out.temp(space='').create()
     return out