Created
March 25, 2024 18:41
-
-
Save CherryDT/648f1018f3a7768016570d1f2c79a167 to your computer and use it in GitHub Desktop.
Python script to download own RecordIt recordings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This Python script downloads all the recordings you made with RecordIt as MP4 and GIF files into the current directory. | |
import requests | |
from bs4 import BeautifulSoup | |
import re | |
import os | |
import sys | |
import glob | |
import xml.etree.ElementTree as ET | |
def find_user_config(): | |
appdata_path = os.environ.get('LOCALAPPDATA') | |
pattern = os.path.join(appdata_path, 'Freshout_Media', 'RecordIt.exe_*', '*', 'user.config') | |
config_files = glob.glob(pattern) | |
if config_files: | |
return config_files[0] # Return the first match | |
return None | |
def extract_recordings_from_config(config_path): | |
tree = ET.parse(config_path) | |
root = tree.getroot() | |
# Navigate through the XML structure to find the 'recordings' setting value | |
for setting in root.iter('setting'): | |
if setting.get('name') == 'recordings': | |
return setting.find('value').text | |
return None | |
def download_files(input_string): | |
# Extract timestamps and video IDs from the input string | |
entries = re.findall(r"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\.000Z%([A-Za-z0-9]+)\|", input_string + "|") | |
for entry in entries: | |
timestamp, video_id = entry | |
formatted_timestamp = timestamp.replace("T", "_").replace(":", "-") | |
video_filename = f"{formatted_timestamp}_{video_id}.mp4" | |
gif_filename = f"{formatted_timestamp}_{video_id}.gif" | |
# Download MP4 | |
url = f"https://recordit.co/{video_id}" | |
try: | |
response = requests.get(url) | |
response.raise_for_status() | |
soup = BeautifulSoup(response.content, 'html.parser') | |
source_tag = soup.find('source', type='video/mp4') | |
if source_tag and 'src' in source_tag.attrs: | |
video_url = source_tag['src'] | |
video_response = requests.get(video_url) | |
video_response.raise_for_status() | |
with open(video_filename, 'wb') as file: | |
file.write(video_response.content) | |
print(f"Downloaded {video_filename}") | |
else: | |
print(f"Video source not found for {video_id}") | |
except Exception as e: | |
print(f"An error occurred for {video_id}: {e}") | |
# Download GIF | |
gif_url = f"http://g.recordit.co/{video_id}.gif" | |
try: | |
gif_response = requests.get(gif_url) | |
gif_response.raise_for_status() | |
with open(gif_filename, 'wb') as file: | |
file.write(gif_response.content) | |
print(f"Downloaded {gif_filename}") | |
except Exception as e: | |
print(f"An error occurred downloading GIF for {video_id}: {e}") | |
print("All downloads attempted.") | |
config_path = find_user_config() | |
if config_path: | |
input_string = extract_recordings_from_config(config_path) | |
if input_string: | |
download_files(input_string) | |
else: | |
print("No recordings found in the config file.") | |
else: | |
print("user.config file not found.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment