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")
def _localM3U8(self, _name) -> None: if _name != '' and self.m3u8Path != '': outputPath = self.output().add(f'{_name}.mp4') initialized = Film.initialize(outputPath, PathModel(self.m3u8Path)) if initialized == "created": self.root.destroy() Downloader(outputPath) else: print(initialized)
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)
def __init__(self, _url: str, outputPath: PathModel) -> None: self.http = urllib3.PoolManager() page = BeautifulSoup( self.http.request('GET', self.newSite() + _url, preload_content=False), 'html.parser') self.name = str( page.find("span", attrs={ "class": "breadcrumb_last" }).string).replace(':', '') self.url = page.iframe['src'] self.m3u8Path = DownloadM3U8().getFilm(self.url) self.outputFile = outputPath.add(f"{self.name}.mp4") self.init = Film.initialize(self.outputFile, self.m3u8Path)
def getFilm(self, url: str) -> PathModel: self.root.get(url) # go to 4k definition button4k = self.root.find_element_by_xpath( "/html/body/div[1]/div[1]/ul/li[3]/a") self.root.get(button4k.get_attribute("href")) embed = self.root.find_element_by_xpath( '/html/body/div[2]/iframe') embedUrl = str(embed.get_attribute("src")) self.root.get(embedUrl.replace("embed", "login")) if re.match(r".*\/login\/.*", self.root.current_url) != None: self._login() m3u8 = self._blob() self.root.quit() return PathModel(os.getcwd()).add(m3u8)
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
def get(name: str) -> PathModel | None: self = Data() if name in self.out.keys(): return PathModel(self.out.get(name)) return None
def init(self, out: PathModel) -> PathModel: out = out.add(self.name) if Data.create(out): out.temp(space='').create() return out
def getSerie(self, outputFolder: PathModel, url: str, all: list[tuple]) -> None: for x in all: _m3u8 = self._getEpisode(url, x) Serie.initialize(x, outputFolder, PathModel(os.getcwd()).add(_m3u8)) self.root.quit()
def output(self) -> PathModel: if self.outBool.get(): return PathModel(filedialog.askdirectory(parent=self.root)) else: return PathModel(os.getcwd())