mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-07-10 23:11:47 +08:00
feat:分享订阅删除功能
This commit is contained in:
@@ -207,6 +207,32 @@ class RequestUtils:
|
||||
raise_exception=raise_exception,
|
||||
**kwargs)
|
||||
|
||||
def delete_res(self,
|
||||
url: str,
|
||||
data: Any = None,
|
||||
params: dict = None,
|
||||
allow_redirects: bool = True,
|
||||
raise_exception: bool = False,
|
||||
**kwargs) -> Optional[Response]:
|
||||
"""
|
||||
发送DELETE请求并返回响应对象
|
||||
:param url: 请求的URL
|
||||
:param data: 请求的数据
|
||||
:param params: 请求的参数
|
||||
:param allow_redirects: 是否允许重定向
|
||||
:param raise_exception: 是否在发生异常时抛出异常,否则默认拦截异常返回None
|
||||
:param kwargs: 其他请求参数,如headers, cookies, proxies等
|
||||
:return: HTTP响应对象,若发生RequestException则返回None
|
||||
:raises: requests.exceptions.RequestException 仅raise_exception为True时会抛出
|
||||
"""
|
||||
return self.request(method="delete",
|
||||
url=url,
|
||||
data=data,
|
||||
params=params,
|
||||
allow_redirects=allow_redirects,
|
||||
raise_exception=raise_exception,
|
||||
**kwargs)
|
||||
|
||||
@staticmethod
|
||||
def cookie_parse(cookies_str: str, array: bool = False) -> Union[list, dict]:
|
||||
"""
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import datetime
|
||||
import hashlib
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import uuid
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Tuple, Union
|
||||
@@ -556,3 +558,45 @@ class SystemUtils:
|
||||
# 确保是空文件夹
|
||||
if folder.is_dir() and not any(folder.iterdir()):
|
||||
folder.rmdir()
|
||||
|
||||
@staticmethod
|
||||
def generate_user_unique_id():
|
||||
"""
|
||||
根据优先级依次尝试生成稳定唯一ID:
|
||||
1. 文件系统唯一标识符。
|
||||
2. MAC 地址。
|
||||
3. 主机名。
|
||||
"""
|
||||
|
||||
def get_filesystem_unique_id():
|
||||
"""
|
||||
获取文件系统的唯一标识符。
|
||||
使用根目录的设备号和 inode。
|
||||
"""
|
||||
try:
|
||||
stat_info = os.stat("/")
|
||||
fs_id = f"{stat_info.st_dev}-{stat_info.st_ino}"
|
||||
return hashlib.sha256(fs_id.encode("utf-8")).hexdigest()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return None
|
||||
|
||||
def get_mac_address_id():
|
||||
"""
|
||||
获取设备的 MAC 地址并生成唯一标识符。
|
||||
"""
|
||||
try:
|
||||
mac_address = uuid.getnode()
|
||||
if (mac_address >> 40) % 2: # 检查是否是虚拟MAC地址
|
||||
raise ValueError("MAC地址可能是虚拟地址")
|
||||
mac_str = f"{mac_address:012x}"
|
||||
return hashlib.sha256(mac_str.encode("utf-8")).hexdigest()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
return None
|
||||
|
||||
for method in [get_filesystem_unique_id, get_mac_address_id]:
|
||||
unique_id = method()
|
||||
if unique_id:
|
||||
return unique_id
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user