update version

Added function for restart streams
main
Phantom 2023-07-16 12:14:21 +03:00
parent 6adbca0cf9
commit bb9541c9ed
1 changed files with 64 additions and 19 deletions

View File

@ -1,5 +1,6 @@
import requests import requests
import getpass import getpass
import time
print(""" print("""
\033[38;5;15m \033[38;5;15m
@ -12,14 +13,13 @@ print("""
Created by Phantom Created by Phantom
Version: 1.0 Version: 2.0
Telegram: https://t.me/PHMSupport Telegram: https://t.me/PHMSupport
Special for: DRMStuff.com Special for: DRMStuff.com
\033[0m \033[0m
\n\n\n\n""") \n\n\n\n""")
def fetch_data(URL, USER, PASSWORD, operationName, variables, query, format_data): def fetch_data(URL, USER, PASSWORD, operationName, variables, query, format_data):
headers = { headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -41,8 +41,6 @@ def fetch_data(URL, USER, PASSWORD, operationName, variables, query, format_data
print("Failed to login") print("Failed to login")
return return
token = response.json()["data"]["login"] token = response.json()["data"]["login"]
headers["Authorization"] = f"Bearer {token}" headers["Authorization"] = f"Bearer {token}"
@ -63,7 +61,8 @@ def print_menu():
print("\033[96m1. Fetch Channels\033[0m") print("\033[96m1. Fetch Channels\033[0m")
print("\033[96m2. Fetch Providers\033[0m") print("\033[96m2. Fetch Providers\033[0m")
print("\033[96m3. Fetch Categories\033[0m") print("\033[96m3. Fetch Categories\033[0m")
print("\033[96m4. Exit\033[0m") print("\033[96m4. Restart Channels\033[0m")
print("\033[96m5. Exit\033[0m")
def format_channels(data): def format_channels(data):
channels = data["data"]["channels"]["channels"] channels = data["data"]["channels"]["channels"]
@ -91,6 +90,52 @@ def format_categories(data):
print(f"Category Label: {category['label']}") print(f"Category Label: {category['label']}")
print("-----------------------------------") print("-----------------------------------")
def restart_channels(URL, CHANNEL_IDS, MPD_PANEL):
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Connection": "keep-alive",
"DNT": "1",
"Origin": f"{URL}/ui",
}
ids = CHANNEL_IDS.split(",")
if MPD_PANEL.lower() == "v3":
for channel_id in ids:
channel_id = channel_id.strip()
restart = {
"operationName": "Restart",
"variables": {
"id": int(channel_id),
},
"query": "query Restart($id: Int!) {\n restart(id: $id)\n}",
}
requests.post(f"{URL}/api/graphql", headers=headers, json=restart)
time.sleep(1)
else:
for channel_id in ids:
channel_id = channel_id.strip()
stop = {
"operationName": "Stop",
"variables": {
"id": int(channel_id),
},
"query": "query Stop($id: Int!) {\n stop(id: $id)\n}",
}
requests.post(f"{URL}/api/graphql", headers=headers, json=stop)
time.sleep(1.5)
start = {
"operationName": "Play",
"variables": {
"id": int(channel_id),
},
"query": "query Play($id: Int!) {\n play(id: $id)\n}",
}
requests.post(f"{URL}/api/graphql", headers=headers, json=start)
time.sleep(1.5)
server_address = input("Enter server address (including port):") server_address = input("Enter server address (including port):")
URL = f"http://{server_address}" URL = f"http://{server_address}"
@ -100,20 +145,20 @@ PASSWORD = getpass.getpass("Enter password: ")
while True: while True:
print_menu() print_menu()
choice = input("Enter your choice: ") choice = input("Enter your choice: ")
if choice == '1':
fetch_data(URL, USER, PASSWORD, "channels", {"limit": 50, "offset": 0, "model": {"lang": "", "provider": "", "searchString": ""}}, if choice == "1":
"query channels($limit: Int!, $offset: Long!, $model: ChannelFilterModel!) {\n channels(limit: $limit, offset: $offset, model: $model) {\n channels {\n id\n name\n lang\n url\n }\n hasMore\n }\n}", fetch_data(URL, USER, PASSWORD, "Channels", {}, "query Channels {\n channels {\n channels {\n id\n name\n lang\n url\n }\n }\n}", format_channels)
format_channels) elif choice == "2":
elif choice == '2': fetch_data(URL, USER, PASSWORD, "Providers", {}, "query Providers {\n providers {\n id\n name\n engine\n proxy\n format\n }\n}", format_providers)
fetch_data(URL, USER, PASSWORD, "providers", {}, elif choice == "3":
"query providers {\n providers {\n id\n name\n engine\n proxy\n format\n }\n}", fetch_data(URL, USER, PASSWORD, "Categories", {}, "query Categories {\n categories {\n id\n label\n }\n}", format_categories)
format_providers) elif choice == "4":
elif choice == '3': CHANNEL_IDS = input("Enter channel ids (comma separated): ")
fetch_data(URL, USER, PASSWORD, "categories", {}, MPD_PANEL = input("Enter MPD Panel version: ")
"query categories {\n categories {\n id\n label\n }\n}", restart_channels(URL, CHANNEL_IDS, MPD_PANEL)
format_categories) elif choice == "5":
elif choice == '4':
break break
else: else:
print("Invalid choice. Please try again.") print("Invalid choice")