mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Sources UP
This commit is contained in:
parent
fd12df4f99
commit
14ae7522d7
3 changed files with 13 additions and 9 deletions
|
|
@ -12,7 +12,7 @@ from app.common.subscriber.login.entry import SubscriberUser
|
|||
from app.common.subscriber.entry import Device
|
||||
from app.service.service import ServiceSettings
|
||||
|
||||
PROJECT_NAME = 'create_provider'
|
||||
PROJECT_NAME = 'import_subscribers_from_xtream'
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(prog=PROJECT_NAME, usage='%(prog)s [options]')
|
||||
|
|
@ -21,12 +21,14 @@ if __name__ == '__main__':
|
|||
parser.add_argument('--mysql_user', help='MySQL username', default='')
|
||||
parser.add_argument('--mysql_password', help='MySQL password', default='')
|
||||
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
|
||||
server_id = argv.server_id
|
||||
country = argv.country
|
||||
|
||||
mongo = connect(host=argv.mongo_uri)
|
||||
if not mongo:
|
||||
|
|
@ -36,24 +38,24 @@ if __name__ == '__main__':
|
|||
if not server:
|
||||
sys.exit(1)
|
||||
|
||||
mydb = mysql.connector.connect(
|
||||
db = mysql.connector.connect(
|
||||
host=mysql_host,
|
||||
user=mysql_user,
|
||||
passwd=mysql_password,
|
||||
database='xtream_iptvpro'
|
||||
)
|
||||
|
||||
mycursor = mydb.cursor(dictionary=True)
|
||||
cursor = db.cursor(dictionary=True)
|
||||
|
||||
sql = 'SELECT username,password,created_at,exp_date FROM users'
|
||||
|
||||
mycursor.execute(sql)
|
||||
cursor.execute(sql)
|
||||
|
||||
myresult = mycursor.fetchall()
|
||||
sql_subscribers = cursor.fetchall()
|
||||
|
||||
for sql_entry in myresult:
|
||||
for sql_entry in sql_subscribers:
|
||||
new_user = SubscriberUser.make_subscriber(email=sql_entry['username'], password=sql_entry['password'],
|
||||
country='US')
|
||||
country=country)
|
||||
new_user.status = SubscriberUser.Status.ACTIVE
|
||||
created_at = sql_entry['created_at']
|
||||
if created_at:
|
||||
|
|
@ -67,4 +69,5 @@ if __name__ == '__main__':
|
|||
new_user.add_server(server)
|
||||
server.add_subscriber(new_user)
|
||||
|
||||
mydb.close()
|
||||
cursor.close()
|
||||
db.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue