mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 20:15:24 +00:00
Fix tmp for mac
This commit is contained in:
parent
e91e1b1aad
commit
602fab9e38
@ -6,7 +6,6 @@ import os
|
|||||||
import random
|
import random
|
||||||
import threading
|
import threading
|
||||||
import json
|
import json
|
||||||
import tempfile
|
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
# Internal utilities
|
# 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)
|
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:
|
def create_or_update_user_agent_file() -> None:
|
||||||
"""
|
"""
|
||||||
Create or update the user agent file with browser user agents.
|
Create or update the user agent file with browser user agents.
|
||||||
@ -80,8 +101,11 @@ class UserAgentManager:
|
|||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
|
# Create temp directory if not exist
|
||||||
|
temp_dir = create_temp_directory()
|
||||||
|
|
||||||
# Get path to temp file where save all user agents
|
# 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 file dont exist, creaet it
|
||||||
if not os.path.exists(self.user_agent_file):
|
if not os.path.exists(self.user_agent_file):
|
||||||
|
@ -4,13 +4,19 @@
|
|||||||
# run somehwere backup
|
# run somehwere backup
|
||||||
# add config to trace if ffmpeg is install, using config in local or temp
|
# add config to trace if ffmpeg is install, using config in local or temp
|
||||||
|
|
||||||
import winreg
|
import platform
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
|
||||||
# Define Windows registry key for user environment variables
|
import winreg
|
||||||
env_keys = winreg.HKEY_CURRENT_USER, "Environment"
|
|
||||||
|
# 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:
|
def get_env(name: str) -> str:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user