mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Port from xtream script
This commit is contained in:
parent
379ae82a8c
commit
cd448cb001
3 changed files with 126 additions and 74 deletions
50
scripts/import_from_xtream.py
Executable file
50
scripts/import_from_xtream.py
Executable file
|
@ -0,0 +1,50 @@
|
||||||
|
#!/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 .import_streams_from_xtream import import_streams_to_server
|
||||||
|
from .import_subscribers_from_xtream import import_subscribers_to_server
|
||||||
|
|
||||||
|
PROJECT_NAME = 'import_streams_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)
|
||||||
|
|
||||||
|
server = ServiceSettings.objects(id=server_id).first()
|
||||||
|
if not server:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
db = mysql.connector.connect(
|
||||||
|
host=mysql_host,
|
||||||
|
port=mysql_port,
|
||||||
|
user=mysql_user,
|
||||||
|
passwd=mysql_password,
|
||||||
|
database='xtream_iptvpro'
|
||||||
|
)
|
||||||
|
|
||||||
|
import_streams_to_server(db, server)
|
||||||
|
import_subscribers_to_server(db, server)
|
||||||
|
db.close()
|
|
@ -15,44 +15,11 @@ import app.common.constants as constants
|
||||||
|
|
||||||
PROJECT_NAME = 'import_streams_from_xtream'
|
PROJECT_NAME = 'import_streams_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)
|
|
||||||
|
|
||||||
server = ServiceSettings.objects(id=server_id).first()
|
|
||||||
if not server:
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
db = mysql.connector.connect(
|
|
||||||
host=mysql_host,
|
|
||||||
port=mysql_port,
|
|
||||||
user=mysql_user,
|
|
||||||
passwd=mysql_password,
|
|
||||||
database='xtream_iptvpro'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
def import_streams_to_server(db, server):
|
||||||
cursor = db.cursor(dictionary=True)
|
cursor = db.cursor(dictionary=True)
|
||||||
|
|
||||||
sql = 'SELECT stream_source, stream_display_name, stream_icon, channel_id from streams'
|
sql = 'SELECT stream_source, stream_display_name, stream_icon, channel_id from streams'
|
||||||
|
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
|
||||||
sql_streams = cursor.fetchall()
|
sql_streams = cursor.fetchall()
|
||||||
|
|
||||||
for sql_entry in sql_streams:
|
for sql_entry in sql_streams:
|
||||||
|
@ -75,6 +42,40 @@ if __name__ == '__main__':
|
||||||
server.streams.append(stream)
|
server.streams.append(stream)
|
||||||
|
|
||||||
server.save()
|
server.save()
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
db.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
|
||||||
|
|
||||||
|
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_streams_to_server(d, ser)
|
||||||
|
d.close()
|
||||||
|
|
|
@ -14,51 +14,16 @@ from app.service.service import ServiceSettings
|
||||||
|
|
||||||
PROJECT_NAME = 'import_subscribers_from_xtream'
|
PROJECT_NAME = 'import_subscribers_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='')
|
|
||||||
parser.add_argument('--country', help='Subscribers country', default='US')
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
server = ServiceSettings.objects(id=server_id).first()
|
|
||||||
if not server:
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
db = mysql.connector.connect(
|
|
||||||
host=mysql_host,
|
|
||||||
port=mysql_port,
|
|
||||||
user=mysql_user,
|
|
||||||
passwd=mysql_password,
|
|
||||||
database='xtream_iptvpro'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
def import_subscribers_to_server(db, server):
|
||||||
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)
|
||||||
|
|
||||||
sql_subscribers = cursor.fetchall()
|
sql_subscribers = cursor.fetchall()
|
||||||
|
|
||||||
for sql_entry in sql_subscribers:
|
for sql_entry in sql_subscribers:
|
||||||
new_user = SubscriberUser.make_subscriber(email=sql_entry['username'], password=sql_entry['password'],
|
new_user = SubscriberUser.make_subscriber(email=sql_entry['username'], password=sql_entry['password'],
|
||||||
country=country)
|
country='US')
|
||||||
new_user.status = SubscriberUser.Status.ACTIVE
|
new_user.status = SubscriberUser.Status.ACTIVE
|
||||||
created_at = sql_entry['created_at']
|
created_at = sql_entry['created_at']
|
||||||
if created_at:
|
if created_at:
|
||||||
|
@ -73,4 +38,40 @@ if __name__ == '__main__':
|
||||||
server.add_subscriber(new_user)
|
server.add_subscriber(new_user)
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
db.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