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)
    import_resellers_to_server(db, server)
    db.close()
Beispiel #2
0
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from app.stream.stream_entry import make_test_life_stream
from app.service.service import ServiceSettings
from app.utils.m3u_parser import M3uParser

PROJECT_NAME = 'test_life'

if __name__ == '__main__':
    parser = argparse.ArgumentParser(prog=PROJECT_NAME,
                                     usage='%(prog)s [options]')
    parser.add_argument('uri', help='Uri to m3u8 list')
    parser.add_argument('mongo_uri', help='MongoDB credentials')

    argv = parser.parse_args()

    mongo = connect(argv.mongo_uri)
    if mongo:
        service_settings = ServiceSettings.objects().first()
        m3u_parser = M3uParser()
        m3u_parser.read_m3u(argv.uri)
        m3u_parser.parse()
        for file in m3u_parser.files:
            stream = make_test_life_stream(service_settings.feedback_directory)
            stream.input.urls[0].uri = file['link']
            stream.name = '{0}({1})'.format(file['tvg-group'], file['title'])
            service_settings.streams.append(stream)

        service_settings.save()