mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Folder for migrate
This commit is contained in:
parent
cd448cb001
commit
a5647b37e5
6 changed files with 218 additions and 64 deletions
42
scripts/migrate/xtream/streams.py
Executable file
42
scripts/migrate/xtream/streams.py
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||
|
||||
from app.common.stream.entry import ProxyStream
|
||||
from app.service.service import ServiceSettings
|
||||
from app.common.utils.utils import is_valid_http_url
|
||||
import app.common.constants as constants
|
||||
|
||||
PROJECT_NAME = 'import_streams_from_xtream'
|
||||
|
||||
|
||||
def import_streams_to_server(db, server: ServiceSettings):
|
||||
cursor = db.cursor(dictionary=True)
|
||||
sql = 'SELECT stream_source, stream_display_name, stream_icon, channel_id from streams'
|
||||
cursor.execute(sql)
|
||||
sql_streams = cursor.fetchall()
|
||||
|
||||
for sql_entry in sql_streams:
|
||||
stream = ProxyStream.make_stream(server)
|
||||
urls = json.loads(sql_entry['stream_source'])
|
||||
if not len(urls):
|
||||
continue
|
||||
|
||||
stream.output.urls[0].uri = urls[0]
|
||||
stream.name = sql_entry['stream_display_name']
|
||||
tvg_logo = sql_entry['stream_icon']
|
||||
if len(tvg_logo) < constants.MAX_URL_LENGTH:
|
||||
if is_valid_http_url(tvg_logo, timeout=0.1):
|
||||
stream.tvg_logo = tvg_logo
|
||||
epg_id = sql_entry['channel_id']
|
||||
if epg_id:
|
||||
stream.tvg_id = epg_id
|
||||
|
||||
stream.save()
|
||||
server.streams.append(stream)
|
||||
|
||||
server.save()
|
||||
cursor.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue