mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Migrate
This commit is contained in:
parent
a5647b37e5
commit
8467058063
4 changed files with 5 additions and 45 deletions
|
@ -8,8 +8,8 @@ import mysql.connector
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
|
|
||||||
from app.service.service import ServiceSettings
|
from app.service.service import ServiceSettings
|
||||||
from migrate.xtream.subscribers import import_subscribers_to_server
|
from .migrate.xtream.subscribers import import_subscribers_to_server
|
||||||
from migrate.xtream.streams import import_streams_to_server
|
from .migrate.xtream.streams import import_streams_to_server
|
||||||
|
|
||||||
PROJECT_NAME = 'import_streams_from_xtream'
|
PROJECT_NAME = 'import_streams_from_xtream'
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import mysql.connector
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
|
|
||||||
from app.service.service import ServiceSettings
|
from app.service.service import ServiceSettings
|
||||||
from migrate.xtream.streams import import_streams_to_server
|
from .migrate.xtream.streams import import_streams_to_server
|
||||||
|
|
||||||
PROJECT_NAME = 'import_streams_from_xtream'
|
PROJECT_NAME = 'import_streams_from_xtream'
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from app.service.service import ServiceSettings
|
||||||
|
|
||||||
PROJECT_NAME = 'import_subscribers_from_xtream'
|
PROJECT_NAME = 'import_subscribers_from_xtream'
|
||||||
|
|
||||||
from migrate.xtream.subscribers import import_subscribers_to_server
|
from .migrate.xtream.subscribers import import_subscribers_to_server
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(prog=PROJECT_NAME, usage='%(prog)s [options]')
|
parser = argparse.ArgumentParser(prog=PROJECT_NAME, usage='%(prog)s [options]')
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from mongoengine import connect
|
|
||||||
import mysql.connector
|
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
|
|
||||||
|
@ -15,7 +12,7 @@ from app.service.service import ServiceSettings
|
||||||
PROJECT_NAME = 'import_subscribers_from_xtream'
|
PROJECT_NAME = 'import_subscribers_from_xtream'
|
||||||
|
|
||||||
|
|
||||||
def import_subscribers_to_server(db, server):
|
def import_subscribers_to_server(db, server: ServiceSettings):
|
||||||
cursor = db.cursor(dictionary=True)
|
cursor = db.cursor(dictionary=True)
|
||||||
sql = 'SELECT username,password,created_at,exp_date FROM users'
|
sql = 'SELECT username,password,created_at,exp_date FROM users'
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
@ -38,40 +35,3 @@ def import_subscribers_to_server(db, server):
|
||||||
server.add_subscriber(new_user)
|
server.add_subscriber(new_user)
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
country = argv.country
|
|
||||||
|
|
||||||
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_subscribers_to_server(d, ser)
|
|
||||||
d.close()
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue