1
0
Fork 0
mirror of https://github.com/fastogt/fastocloud_admin.git synced 2025-03-09 23:38:52 +00:00

Import resellers

This commit is contained in:
topilski 2019-09-22 03:06:31 -04:00
parent a69a2960af
commit 10bb740ad8
5 changed files with 67 additions and 6 deletions

View file

@ -10,6 +10,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from app.service.service import ServiceSettings from app.service.service import ServiceSettings
from scripts.migrate.xtream.subscribers import import_subscribers_to_server from scripts.migrate.xtream.subscribers import import_subscribers_to_server
from scripts.migrate.xtream.streams import import_streams_to_server from scripts.migrate.xtream.streams import import_streams_to_server
from scripts.migrate.xtream.resellers import import_resellers_to_server
PROJECT_NAME = 'import_streams_from_xtream' PROJECT_NAME = 'import_streams_from_xtream'
@ -47,4 +48,5 @@ if __name__ == '__main__':
import_streams_to_server(db, server) import_streams_to_server(db, server)
import_subscribers_to_server(db, server) import_subscribers_to_server(db, server)
import_resellers_to_server(dv, server)
db.close() db.close()

View file

@ -0,0 +1,48 @@
#!/usr/bin/env python3
import argparse
import os
import sys
from mongoengine import connect
import mysql.connector
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from app.service.service import ServiceSettings
from scripts.migrate.xtream.resellers import import_resellers_to_server
PROJECT_NAME = 'import_resellers_from_xtream'
if __name__ == '__main__':
parser = argparse.ArgumentParser(prog=PROJECT_NAME, usage='%(prog)s [options]')
parser.add_argument('--mongo_uri', help='MongoDB credentials', default='mongodb://localhost:27017/iptv')
parser.add_argument('--mysql_host', help='MySQL host', default='localhost')
parser.add_argument('--mysql_user', help='MySQL username', default='root')
parser.add_argument('--mysql_password', help='MySQL password', default='')
parser.add_argument('--mysql_port', help='MySQL port', default=3306)
parser.add_argument('--server_id', help='Server ID', default='')
argv = parser.parse_args()
mysql_host = argv.mysql_host
mysql_user = argv.mysql_user
mysql_password = argv.mysql_password
mysql_port = argv.mysql_port
server_id = argv.server_id
mongo = connect(host=argv.mongo_uri)
if not mongo:
sys.exit(1)
ser = ServiceSettings.objects(id=server_id).first()
if not ser:
sys.exit(1)
d = mysql.connector.connect(
host=mysql_host,
port=mysql_port,
user=mysql_user,
passwd=mysql_password,
database='xtream_iptvpro'
)
import_resellers_to_server(d, ser)
d.close()

View file

@ -0,0 +1,17 @@
from app.home.entry import ProviderUser
from app.service.service import ServiceSettings
def import_resellers_to_server(db, server: ServiceSettings):
cursor = db.cursor(dictionary=True)
sql = 'SELECT username,password from reg_users'
cursor.execute(sql)
sql_providers = cursor.fetchall()
for sql_entry in sql_providers:
new_user = ProviderUser.make_provider(email=sql_entry['username'], password=sql_entry['username'], country='US')
new_user.status = ProviderUser.Status.ACTIVE
new_user.add_server(server)
server.add_provider(new_user)
cursor.close()

View file

@ -1,4 +1,3 @@
#!/usr/bin/env python3
import json import json
from app.common.stream.entry import ProxyStream from app.common.stream.entry import ProxyStream
@ -6,8 +5,6 @@ from app.service.service import ServiceSettings
from app.common.utils.utils import is_valid_http_url from app.common.utils.utils import is_valid_http_url
import app.common.constants as constants import app.common.constants as constants
PROJECT_NAME = 'import_streams_from_xtream'
def import_streams_to_server(db, server: ServiceSettings): def import_streams_to_server(db, server: ServiceSettings):
cursor = db.cursor(dictionary=True) cursor = db.cursor(dictionary=True)

View file

@ -1,12 +1,9 @@
#!/usr/bin/env python3
from datetime import datetime from datetime import datetime
from app.common.subscriber.login.entry import SubscriberUser from app.common.subscriber.login.entry import SubscriberUser
from app.common.subscriber.entry import Device from app.common.subscriber.entry import Device
from app.service.service import ServiceSettings from app.service.service import ServiceSettings
PROJECT_NAME = 'import_subscribers_from_xtream'
def import_subscribers_to_server(db, server: ServiceSettings): def import_subscribers_to_server(db, server: ServiceSettings):
cursor = db.cursor(dictionary=True) cursor = db.cursor(dictionary=True)