feat: 增加 subscription set-url 方法
This commit is contained in:
@ -21,7 +21,7 @@ class SubscriptionManager:
|
||||
self.subscriptions_dir = self.storage.config_dir / "subscriptions"
|
||||
self.subscriptions_dir.mkdir(exist_ok=True)
|
||||
|
||||
def add_subscription(self, url: str, name: str) -> None:
|
||||
def add_subscription(self, name: str, url: str) -> None:
|
||||
"""Add a new subscription."""
|
||||
subscription = self.subscriptions_data.add_subscription(name, url)
|
||||
|
||||
@ -45,11 +45,12 @@ class SubscriptionManager:
|
||||
try:
|
||||
# Download the subscription content
|
||||
headers = {
|
||||
'User-Agent': self.config.default_user_agent
|
||||
# 'User-Agent': self.config.default_user_agent
|
||||
}
|
||||
timeout = self.config.timeout_seconds
|
||||
# timeout = self.config.timeout_seconds
|
||||
|
||||
response = requests.get(url, headers=headers, timeout=timeout)
|
||||
# response = requests.get(url, headers=headers, timeout=timeout)
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
|
||||
# File path without timestamp
|
||||
@ -121,6 +122,16 @@ class SubscriptionManager:
|
||||
else:
|
||||
print(f"❌ Failed to rename subscription: '{old_name}' not found or '{new_name}' already exists")
|
||||
|
||||
def set_subscription_url(self, name: str, url: str) -> None:
|
||||
"""Update the URL for a subscription."""
|
||||
if self.subscriptions_data.set_subscription_url(name, url):
|
||||
if self.storage.save_subscriptions(self.subscriptions_data):
|
||||
print(f"✅ Updated URL for subscription '{name}': {url}")
|
||||
else:
|
||||
print("❌ Failed to save subscription")
|
||||
else:
|
||||
print(f"❌ Subscription '{name}' not found")
|
||||
|
||||
def activate_subscription(self, name: str) -> None:
|
||||
"""Activate a subscription."""
|
||||
if self.subscriptions_data.set_active(name):
|
||||
|
||||
Reference in New Issue
Block a user