def main(): custom_formatters = [ formatters.Label(), formatters.Text(': [', style='class:percentage'), formatters.Percentage(), formatters.Text(']', style='class:percentage'), formatters.Text(' '), formatters.Bar(sym_a='#', sym_b='#', sym_c='.'), formatters.Text(' '), ] with ProgressBar(style=style, formatters=custom_formatters) as pb: for i in pb(range(1600), label='Installing'): time.sleep(.01)
def main(): custom_formatters = [ formatters.Label(), formatters.Text(": [", style="class:percentage"), formatters.Percentage(), formatters.Text("]", style="class:percentage"), formatters.Text(" "), formatters.Bar(sym_a="#", sym_b="#", sym_c="."), formatters.Text(" "), ] with ProgressBar(style=style, formatters=custom_formatters) as pb: for i in pb(range(1600), label="Installing"): time.sleep(0.01)
def main(): custom_formatters = [ formatters.Label(suffix=': '), formatters.Percentage(), formatters.Bar(start='|', end='|', sym_a=' ', sym_b=' ', sym_c=' '), formatters.Text(' '), formatters.Progress(), formatters.Text(' ['), formatters.TimeElapsed(), formatters.Text('<'), formatters.TimeLeft(), formatters.Text(', '), formatters.IterationsPerSecond(), formatters.Text('it/s]'), ] with ProgressBar(style=style, formatters=custom_formatters) as pb: for i in pb(range(1600), label='Installing'): time.sleep(.01)
def main(): custom_formatters = [ formatters.Label(suffix=": "), formatters.Percentage(), formatters.Bar(start="|", end="|", sym_a=" ", sym_b=" ", sym_c=" "), formatters.Text(" "), formatters.Progress(), formatters.Text(" ["), formatters.TimeElapsed(), formatters.Text("<"), formatters.TimeLeft(), formatters.Text(", "), formatters.IterationsPerSecond(), formatters.Text("it/s]"), ] with ProgressBar(style=style, formatters=custom_formatters) as pb: for i in pb(range(1600), label="Installing"): time.sleep(0.01)
SWIGGY_URL = 'https://www.swiggy.com' SWIGGY_LOGIN_URL = SWIGGY_URL + '/dapi/auth/signin-with-check' SWIGGY_ORDER_URL = SWIGGY_URL + '/dapi/order/all' SWIGGY_SEND_OTP_URL = SWIGGY_URL + '/dapi/auth/sms-otp' SWIGGY_VERIFY_OTP_URL = SWIGGY_URL + '/dapi/auth/otp-verify' SWIGGY_API_CALL_INTERVAL = 1.5 # interval between API calls. (in seconds) CONFIG_FILEPATH = os.path.join( str(Path.home()), '.swiggy-analytics-config.ini') DB_FILEPATH = os.path.join(str(os.getcwd()), 'swiggy.db') PROGRESS_BAR_STYLE = Style.from_dict({ 'label': 'bg:#FFA500 #000000', 'percentage': 'bg:#FFA500 #000000', 'current': '#448844', 'bar': '', }) PROGRESS_BAR_FORMATTER = [ formatters.Label(), formatters.Text(': [', style='class:percentage'), formatters.Percentage(), formatters.Text(']', style='class:percentage'), formatters.Text(' '), formatters.Bar(sym_a='#', sym_b='#', sym_c='.'), formatters.Text(' '), ] YES_ANSWER_CHOICES = ['y', 'yes', 'yeah', 'yup'] NO_ANSWER_CHOICES = ['n', 'no', 'nope']
def download_footage(self, output_path=Path('downloaded_clips')): """ - Search for footage & get ID values - Try to get the sizes for each clip - Download each clip on it's own - Name the clip and save it to disk in a folder for each camera """ example = "/api/2.0/recording/5bb829e4b3a28701fe50b258/download" meta_cookies = {'cameras.isManagedFilterOn': 'false'} meta_cookies.update(self.session.cookies) # num_clips = len(self.clip_meta_data) url_id_params = str() # Progress Bar Styles and Format style = Style.from_dict({ 'label': 'bg:#000000 #ffffff', 'percentage': 'bg:#000000 #ffffff', 'current': '#448844', 'bar': '', }) custom_formatters = [ formatters.Label(), formatters.Text(': [', style='class:percentage'), formatters.Percentage(), formatters.Text(']', style='class:percentage'), formatters.Text(' '), formatters.Bar(start='[', end=']', sym_a='#', sym_b='>', sym_c='*'), formatters.Text(' '), ] # Create output if it doesn't exist yet self.outputPathCheck(output_path) # pprint(self.dict_info_clip, indent=4) num_clips = len(self.dict_info_clip) with ProgressBar(style=style, formatters=custom_formatters) as pb: for clip in pb(list(self.dict_info_clip), label=f"Downloading {num_clips} Videos", remove_when_done=False): req = requests.Request( 'GET', f"{self.url}/api/2.0/recording/{self.dict_info_clip[clip].clip_id}/download", cookies=meta_cookies) prepped = req.prepare() # print(prepped.url) self.logger.debug( f'Attempting to download clip {self.dict_info_clip[clip].clip_id}' ) r = self.session.send(prepped, stream=True) if r.status_code is 200: self.logger.debug( f'Successfully requested clip {self.dict_info_clip[clip].clip_id}' ) elif r.status_code is 401: self.logger.critical(f'Unauthorized, exiting.') sys.exit(1) else: self.logger.critical( f'Unexpected error occured: {r.status_code}. Exiting.') # pprint(r.text) sys.exit(1) total = r.headers.get('Content-Length') num_chunks = round(int(total) / self.chunk_size) file_path = Path( output_path, self.dict_info_clip[clip].cameraName.replace(' ', '_'), self.dict_info_clip[clip].fullFileName) if not file_path.parent.exists(): file_path.parent.mkdir(exist_ok=True) with open(file_path, 'wb') as f: for data in pb( r.iter_content(chunk_size=self.chunk_size), total=num_chunks, label=f'Downloading', remove_when_done=False, ): f.write(data)