def __downloadVideo__(conf, video, album=None, playlist=None): msg, stream = API.getVideoStreamUrl(video.id, conf.videoQuality) if not isNull(msg): Printf.err(video.title + "." + msg) return path = __getVideoPath__(conf, video, album, playlist) if m3u8Helper.download(stream.m3u8Url, path): Printf.success(getFileName(path)) else: Printf.err("\nDownload failed!" + getFileName(path))
def downloadVideo(self, video, quality): #msg, video = self.api.__get__(f'videos/{video}') self.api.key.accessToken = self.user.assesstoken self.api.key.userId = self.user.userid self.api.key.countryCode = self.user.countryCode self.api.key.sessionId = self.user.sessionid2 if not isNull( self.user.sessionid2) else self.user.sessionid1 msg, stream = self.getVideoStreamUrl(video['id'], quality) if not isNull(msg): print(video['title'] + "." + msg) return # CHANGE THIS LINE TO CHANGE THE FILENAME videofile = library + "/" + replaceLimitChar( f"{artist} - {video['title']} ({video['id']})", "_") + ".mkv" path = library + "/" + replaceLimitChar( f"{video['title']} ({video['id']})", "_") + ".mp4" filename = str(video['id']) filtetitle = str(video['title']) if not os.path.exists("/config/logs/tidal/" + replaceLimitChar( f"{artist} - {video['title']} ({video['id']})", "_")): if not m3u8Helper.download(stream['m3u8Url'], path): print("\nDownload failed!") else: subprocess.call([ 'ffmpeg', '-y', '-ss', '10', '-i', path, '-frames:v', '1', '-vf', str("scale=640:-2"), 'cover.jpg' ]) subprocess.call([ 'ffmpeg', '-i', path, '-c', 'copy', '-metadata', 'title=' + filtetitle, '-metadata', 'ARTIST=' + artist, '-metadata', 'ENCODED_BY=AMVD', '-metadata', 'CONTENT_TYPE=Music Video', '-attach', 'cover.jpg', '-metadata:s:t', 'mimetype=image/jpeg', '-y', videofile ]) subprocess.call( ['mkvpropedit', videofile, '--add-track-statistics-tags']) subprocess.call(['rm', path]) subprocess.call(['rm', 'cover.jpg']) f = open( "/config/logs/tidal/" + replaceLimitChar( f"{artist} - {video['title']} ({video['id']})", "_"), "w") f.write("Download Success") f.close() else: print("Already Downloaded!!!")