mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Change api
This commit is contained in:
parent
bea0055409
commit
a3cd10dfdd
28
README.md
28
README.md
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
# 📋 Table of Contents
|
# 📋 Table of Contents
|
||||||
|
|
||||||
- 🌐 [Website available](https://www.npoint.io/docs/e67633acc3816cc70132)
|
|
||||||
- 🔄 [Update Domains](#update-domains)
|
- 🔄 [Update Domains](#update-domains)
|
||||||
- 🛠️ [Installation](#installation)
|
- 🛠️ [Installation](#installation)
|
||||||
- 📦 [PyPI Installation](#1-pypi-installation)
|
- 📦 [PyPI Installation](#1-pypi-installation)
|
||||||
@ -448,13 +447,15 @@ You can download VLC Media Player from the [official website](https://www.videol
|
|||||||
- `get_only_link`: Return M3U8 playlist/index URL instead of downloading
|
- `get_only_link`: Return M3U8 playlist/index URL instead of downloading
|
||||||
|
|
||||||
|
|
||||||
## 🔄 Update Domains
|
## Update Domains
|
||||||
|
|
||||||
To update the domains for the supported websites:
|
There are two ways to update the domains for the supported websites:
|
||||||
|
|
||||||
1. Visit the configuration endpoint: https://www.npoint.io/docs/e67633acc3816cc70132
|
### 1. Using Local Configuration
|
||||||
|
|
||||||
2. You'll find a JSON structure similar to:
|
1. Create a `domains.json` file in the root directory of the project
|
||||||
|
|
||||||
|
2. Add your domain configuration in the following format:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"altadefinizione": {
|
"altadefinizione": {
|
||||||
@ -465,15 +466,20 @@ To update the domains for the supported websites:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Update the following fields for each website as needed:
|
3. Set `use_api` to `false` in the `DEFAULT` section of your `config.json`:
|
||||||
- `domain`: The new domain extension
|
```json
|
||||||
- `full_url`: The complete URL including the new domain
|
{
|
||||||
|
"DEFAULT": {
|
||||||
|
"use_api": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
4. Save your changes on the npoint.io interface
|
### 2. Using API (Legacy)
|
||||||
|
|
||||||
5. Re-run the script to use the updated domain information
|
The API-based domain updates are currently deprecated. To use it anyway, set `use_api` to `true` in your `config.json` file.
|
||||||
|
|
||||||
Note: The script will automatically fetch the latest domain information from the configuration endpoint when executed.
|
Note: If `use_api` is set to `false` and no `domains.json` file is found, the script will raise an error.
|
||||||
|
|
||||||
# COMMAND
|
# COMMAND
|
||||||
|
|
||||||
|
@ -28,12 +28,31 @@ class ConfigManager:
|
|||||||
else:
|
else:
|
||||||
base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||||
self.file_path = os.path.join(base_path, file_name)
|
self.file_path = os.path.join(base_path, file_name)
|
||||||
|
self.domains_path = os.path.join(base_path, 'domains.json')
|
||||||
self.config = {}
|
self.config = {}
|
||||||
self.configSite = {}
|
self.configSite = {}
|
||||||
self.cache = {}
|
self.cache = {}
|
||||||
|
|
||||||
|
# Read initial config to get use_api setting
|
||||||
|
self._read_initial_config()
|
||||||
|
|
||||||
console.print(f"[bold cyan]📂 Configuration file path:[/bold cyan] [green]{self.file_path}[/green]")
|
console.print(f"[bold cyan]📂 Configuration file path:[/bold cyan] [green]{self.file_path}[/green]")
|
||||||
|
|
||||||
|
def _read_initial_config(self) -> None:
|
||||||
|
"""Read initial configuration to get use_api setting."""
|
||||||
|
try:
|
||||||
|
if os.path.exists(self.file_path):
|
||||||
|
with open(self.file_path, 'r') as f:
|
||||||
|
self.config = json.load(f)
|
||||||
|
self.use_api = self.config.get('DEFAULT', {}).get('use_api', True)
|
||||||
|
else:
|
||||||
|
self.use_api = True # Default to True if config file doesn't exist
|
||||||
|
console.print("[bold yellow]⚠️ Configuration file not found. Using default settings.[/bold yellow]")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
self.use_api = True # Default to True in case of error
|
||||||
|
logging.error(f"❌ Error reading initial configuration: {e}")
|
||||||
|
|
||||||
def read_config(self) -> None:
|
def read_config(self) -> None:
|
||||||
"""Read the configuration file."""
|
"""Read the configuration file."""
|
||||||
try:
|
try:
|
||||||
@ -91,20 +110,41 @@ class ConfigManager:
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def update_site_config(self) -> None:
|
def update_site_config(self) -> None:
|
||||||
"""Fetch and update the site configuration with data from the API."""
|
"""Fetch and update the site configuration with data from the API or local file."""
|
||||||
api_url = "https://api.npoint.io/e67633acc3816cc70132"
|
if self.use_api:
|
||||||
|
headers = {
|
||||||
|
"apikey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2Zm5ncG94d3Jnc3duenl0YWRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAxNTIxNjMsImV4cCI6MjA1NTcyODE2M30.FNTCCMwi0QaKjOu8gtZsT5yQttUW8QiDDGXmzkn89QE",
|
||||||
|
"Authorization": f"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2Zm5ncG94d3Jnc3duenl0YWRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAxNTIxNjMsImV4cCI6MjA1NTcyODE2M30.FNTCCMwi0QaKjOu8gtZsT5yQttUW8QiDDGXmzkn89QE",
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
console.print("[bold cyan]🌍 Fetching SITE data from API...[/bold cyan]")
|
console.print("[bold cyan]🌍 Fetching SITE data from API...[/bold cyan]")
|
||||||
response = requests.get(api_url)
|
response = requests.get("https://zvfngpoxwrgswnzytadh.supabase.co/rest/v1/public", headers=headers)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
self.configSite = response.json() # Store API data in separate configSite
|
self.configSite = response.json()[0]['data']
|
||||||
console.print("[bold green]✅ SITE data successfully fetched.[/bold green]")
|
console.print("[bold green]✅ SITE data successfully fetched.[/bold green]")
|
||||||
else:
|
else:
|
||||||
console.print(f"[bold red]❌ Failed to fetch SITE data. HTTP Status code: {response.status_code}[/bold red]")
|
console.print(f"[bold red]❌ Failed to fetch SITE data. HTTP Status code: {response.status_code}[/bold red]")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
console.print(f"[bold red]❌ Error fetching SITE data: {e}[/bold red]")
|
console.print(f"[bold red]❌ Error fetching SITE data: {e}[/bold red]")
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
if os.path.exists(self.domains_path):
|
||||||
|
console.print("[bold cyan]📖 Reading domains from local file...[/bold cyan]")
|
||||||
|
with open(self.domains_path, 'r') as f:
|
||||||
|
self.configSite = json.load(f)
|
||||||
|
console.print("[bold green]✅ Domains loaded successfully from local file.[/bold green]")
|
||||||
|
else:
|
||||||
|
error_msg = "❌ domains.json not found and API usage is disabled"
|
||||||
|
console.print(f"[bold red]{error_msg}[/bold red]")
|
||||||
|
raise FileNotFoundError(error_msg)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
console.print(f"[bold red]❌ Error reading domains file: {e}[/bold red]")
|
||||||
|
raise
|
||||||
|
|
||||||
def read_key(self, section: str, key: str, data_type: type = str, from_site: bool = False) -> Any:
|
def read_key(self, section: str, key: str, data_type: type = str, from_site: bool = False) -> Any:
|
||||||
"""Read a key from the configuration.
|
"""Read a key from the configuration.
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
"user": "admin",
|
"user": "admin",
|
||||||
"pass": "adminadmin"
|
"pass": "adminadmin"
|
||||||
},
|
},
|
||||||
|
"use_api": true,
|
||||||
"add_siteName": false,
|
"add_siteName": false,
|
||||||
"disable_searchDomain": false,
|
"disable_searchDomain": false,
|
||||||
"not_close": false,
|
"not_close": false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user