Add 'mpdpcontrol.py'

main
Phantom 2023-07-12 08:53:11 +03:00
parent 9d48e1464a
commit 7434625669
1 changed files with 119 additions and 0 deletions

119
mpdpcontrol.py 100644
View File

@ -0,0 +1,119 @@
import requests
import getpass
print("""
\033[38;5;15m
__ ______ ___ ___ _____ __ __
/ |/ / _ \/ _ \/ _ \ / ___/__ ___ / /________ / /
/ /|_/ / ___/ // / ___/ / /__/ _ \/ _ \/ __/ __/ _ \/ /
/_/ /_/_/ /____/_/ \___/\___/_//_/\__/_/ \___/_/
Created by Phantom
Version: 1.0
Telegram: https://t.me/PHMSupport
Special for: DRMStuff.com
\033[0m
\n\n\n\n""")
def fetch_data(URL, USER, PASSWORD, operationName, variables, query, format_data):
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Connection": "keep-alive",
"DNT": "1",
"Origin": f"{URL}/ui",
}
login_data = {
"operationName": "login",
"variables": {"login": USER, "password": PASSWORD},
"query": "mutation login($login: String!, $password: String!) {\n login(login: $login, password: $password)\n}",
}
response = requests.post(f"{URL}/api/graphql", headers=headers, json=login_data)
if response.status_code != 200:
print("Failed to login")
return
token = response.json()["data"]["login"]
headers["Authorization"] = f"Bearer {token}"
data = {
"operationName": operationName,
"variables": variables,
"query": query,
}
response = requests.post(f"{URL}/api/graphql", headers=headers, json=data)
if response.status_code == 200:
format_data(response.json())
else:
print("Failed to fetch data")
def print_menu():
print("\033[96m1. Fetch Channels\033[0m")
print("\033[96m2. Fetch Providers\033[0m")
print("\033[96m3. Fetch Categories\033[0m")
print("\033[96m4. Exit\033[0m")
def format_channels(data):
channels = data["data"]["channels"]["channels"]
for channel in channels:
print(f"Channel ID: {channel['id']}")
print(f"Channel Name: {channel['name']}")
print(f"Channel Language: {channel['lang']}")
print(f"Channel URL: {channel['url']}")
print("-----------------------------------")
def format_providers(data):
providers = data["data"]["providers"]
for provider in providers:
print(f"Provider ID: {provider['id']}")
print(f"Provider Name: {provider['name']}")
print(f"Engine: {provider['engine']}")
print(f"Proxy: {provider['proxy']}")
print(f"Format: {provider['format']}")
print("-----------------------------------")
def format_categories(data):
categories = data["data"]["categories"]
for category in categories:
print(f"Category ID: {category['id']}")
print(f"Category Label: {category['label']}")
print("-----------------------------------")
server_address = input("Enter server address (including port):")
URL = f"http://{server_address}"
USER = input("Enter username: ")
PASSWORD = getpass.getpass("Enter password: ")
while True:
print_menu()
choice = input("Enter your choice: ")
if choice == '1':
fetch_data(URL, USER, PASSWORD, "channels", {"limit": 50, "offset": 0, "model": {"lang": "", "provider": "", "searchString": ""}},
"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}",
format_channels)
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)
elif choice == '3':
fetch_data(URL, USER, PASSWORD, "categories", {},
"query categories {\n categories {\n id\n label\n }\n}",
format_categories)
elif choice == '4':
break
else:
print("Invalid choice. Please try again.")