mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 03:55:24 +00:00
Merge 602fab9e38ccff7d166848d2f11adc487b21fd90 into e91e1b1aad1071b479d6200e085a300fa67094ea
This commit is contained in:
commit
03eefdf5a8
@ -6,7 +6,6 @@ import os
|
||||
import random
|
||||
import threading
|
||||
import json
|
||||
import tempfile
|
||||
from typing import Dict, List
|
||||
|
||||
# Internal utilities
|
||||
@ -48,6 +47,28 @@ def update_user_agents(browser_name: str, browser_user_agents: Dict[str, List[st
|
||||
browser_user_agents[browser_name] = get_browser_user_agents_online(browser_name)
|
||||
|
||||
|
||||
def create_temp_directory():
|
||||
"""
|
||||
Create the TEMP directory if it doesn't exist.
|
||||
|
||||
If the TEMP environment variable doesn't exist, this function creates
|
||||
the TEMP directory in the user's local AppData folder.
|
||||
|
||||
Returns:
|
||||
str: The path to the TEMP directory.
|
||||
"""
|
||||
|
||||
# Get the TEMP directory from the environment variables
|
||||
temp_dir = os.environ.get('TEMP')
|
||||
|
||||
# If TEMP directory is not set, create it in the local AppData folder
|
||||
if temp_dir is None:
|
||||
temp_dir = os.path.join(os.path.expanduser("~"), "AppData", "Local", "Temp")
|
||||
os.makedirs(temp_dir, exist_ok=True)
|
||||
|
||||
return temp_dir
|
||||
|
||||
|
||||
def create_or_update_user_agent_file() -> None:
|
||||
"""
|
||||
Create or update the user agent file with browser user agents.
|
||||
@ -80,8 +101,11 @@ class UserAgentManager:
|
||||
"""
|
||||
def __init__(self):
|
||||
|
||||
# Create temp directory if not exist
|
||||
temp_dir = create_temp_directory()
|
||||
|
||||
# Get path to temp file where save all user agents
|
||||
self.user_agent_file = os.path.join(tempfile.gettempdir(), 'fake_user_agent.json')
|
||||
self.user_agent_file = os.path.join(temp_dir, 'fake_user_agent.json')
|
||||
|
||||
# If file dont exist, creaet it
|
||||
if not os.path.exists(self.user_agent_file):
|
||||
|
@ -4,13 +4,19 @@
|
||||
# run somehwere backup
|
||||
# add config to trace if ffmpeg is install, using config in local or temp
|
||||
|
||||
import winreg
|
||||
import platform
|
||||
import os
|
||||
import logging
|
||||
|
||||
if platform.system() == "Windows":
|
||||
|
||||
# Define Windows registry key for user environment variables
|
||||
env_keys = winreg.HKEY_CURRENT_USER, "Environment"
|
||||
import winreg
|
||||
|
||||
# Define Windows registry key for user environment variables
|
||||
env_keys = winreg.HKEY_CURRENT_USER, "Environment"
|
||||
|
||||
else:
|
||||
env_keys = None
|
||||
|
||||
|
||||
def get_env(name: str) -> str:
|
||||
|
Loading…
x
Reference in New Issue
Block a user