Open alwilliamsii opened 2 years ago
@alwilliamsii if you have some issues with the special character in topic names as well as long filepath limitation in windows (260 characters), you may try to do something like this:
#remove all shitty characters from the meeting name
topic = re.sub('[\W_]+', ' ', topic)
#make sure the filename will not be so long
truncated_file_name = file_name[0:200]
See #25.
I am new to Python and it may be a simple fix. The script is running correctly until it hits : " ? reserve characters. I added topic = recording['topic'].replace('/', '&') #Added ,':' topic = recording['topic'].replace(':', '-') topic = recording['topic'].replace('"', '-') topic = recording['topic'].replace('?', '-') filename = filename.replace(':', '-') filename = filename.replace('"', '-') filename = filename.replace('?', '-') foldername = foldername.replace(':', '-') for each type that is offending.[ "?/\:] to rename topics and file names
: But when I get to the section "def download_recording(download_url, email, filename, foldername): "
-Error Example- ==> Downloading (9 of 13) as chat_file: a5481555-25ac-42bb-a4bc-cddcca46dece: ht tps://j.zoom.us/rec/download/1vZ9X-2OejvpWPx9qeMJ7... 0%| | 0.00/345 [00:00<?, ?iB/s][ Errno 2] No such file or directory: 'z:\video\EDHE 802- Higher Education Leade rship & Organization in Cross-Culture - 2020.10.22 - 01.58 PM UTC\2020.10.22 - 01.58 PM UTC - EDHE 802- Higher Education Leadership & Organization in Cross-Cu lture - Chat File - a5481555-25ac-42bb-a4bc-cddcca46dece.txt' 0%| | 0.00/345 [00:00<?, ?iB/s]
/*****Code With Changes****/
!/usr/bin/env python3
Program Name: zoom-recording-downloader.py
Description: Zoom Recording Downloader is a cross-platform Python script
that uses Zoom's API (v2) to download and organize all
cloud recordings from a Zoom account onto local storage.
This Python script uses the JSON Web Token (JWT)
method of accessing the Zoom API
Created: 2020-04-26
Author: Ricardo Rodrigues
Website: https://github.com/ricardorodrigues-ca/zoom-recording-downloader
Forked from: https://gist.github.com/danaspiegel/c33004e52ffacb60c24215abf8301680
Import TQDM progress bar library
from tqdm import tqdm
Import app environment variables
from appenv import JWT_TOKEN from sys import exit from signal import signal, SIGINT from dateutil.parser import parse import datetime from datetime import date from dateutil import relativedelta from datetime import date, timedelta import itertools import requests import time import sys import os APP_VERSION = "2.1"
JWT_TOKEN now lives in appenv.py
ACCESS_TOKEN = 'Bearer ' + JWT_TOKEN AUTHORIZATION_HEADER = {'Authorization': ACCESS_TOKEN}
API_ENDPOINT_USER_LIST = 'https://api.zoom.us/v2/users'
Start date now split into YEAR, MONTH, and DAY variables (Within 6 month range)
RECORDING_START_YEAR = 2019 RECORDING_START_MONTH = 1 RECORDING_START_DAY = 1 RECORDING_END_DATE = date.today() RECORDING_END_DATE = date(2022, 7, 25) DOWNLOAD_DIRECTORY = r'z:\video' COMPLETED_MEETING_IDS_LOG = 'completed-downloads.log' COMPLETED_MEETING_IDS = set()
define class for text colouring and highlighting
class color: PURPLE = '\033[95m' CYAN = '\033[96m' DARKCYAN = '\033[36m' BLUE = '\033[94m' GREEN = '\033[92m' YELLOW = '\033[93m' RED = '\033[91m' BOLD = '\033[1m' UNDERLINE = '\033[4m' END = '\033[0m'
def API_ENDPOINT_RECORDING_LIST(email): API_ENDPOINT = 'https://api.zoom.us/v2/users/' + email + '/recordings' return API_ENDPOINT
def get_credentials(host_id, page_number, rec_start_date): return { 'host_id': host_id, 'page_number': page_number, 'from': rec_start_date, }
def get_user_ids():
get total page count, convert to integer, increment by 1
def format_filename(recording, file_type, file_extension, recording_type, recording_id): uuid = recording['uuid'] topic = recording['topic'].replace('/', '&') # Added 7/272022 Al Williams topic = recording['topic'].replace(':', '-') topic = recording['topic'].replace('"', '-') topic = recording['topic'].replace('?', '-')# End of Added 7/272022 Al Williams rec_type = recordingtype.replace("", " ").title() meeting_time = parse(recording['start_time']).strftime('%Y.%m.%d - %I.%M %p UTC') return '{} - {} - {}.{}'.format( meeting_time, topic+" - "+rec_type, recording_id, file_extension.lower()),'{} - {}'.format(topic, meeting_time)
def get_downloads(recording): downloads = [] for download in recording['recording_files']: file_type = download['file_type'] file_extension = download['file_extension'] recording_id = download['id'] if file_type == "": recording_type = 'incomplete'
print("\download is: {}".format(download))
def get_recordings(email, page_size, rec_start_date, rec_end_date): return { 'userId': email, 'page_size': page_size, 'from': rec_start_date, 'to': rec_end_date }
Generator used to create deltas for recording start and end dates
def perdelta(start, end, delta): curr = start while curr < end: yield curr, min(curr + delta, end) curr += delta
def list_recordings(email): recordings = []
Added 7/272022 Al Williams
End of Added 7/272022 Al Williams
def download_recording(download_url, email, filename, foldername):
dl_dir = os.sep.join([DOWNLOAD_DIRECTORY, foldername])
def load_completed_meeting_ids(): try: with open(COMPLETED_MEETING_IDS_LOG, 'r') as fd: for line in fd: COMPLETED_MEETING_IDS.add(line.strip()) except FileNotFoundError: print("Log file not found. Creating new log file: ", COMPLETED_MEETING_IDS_LOG) print()
def handler(signal_received, frame):
handle cleanup here
MAIN
def main():
'''.format(APP_VERSION))
if name == "main":
tell Python to run the handler() function when SIGINT is recieved