mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Fixed m3u
This commit is contained in:
parent
c3b15c2102
commit
60b1afd969
2 changed files with 42 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
from flask_classy import FlaskView, route
|
from flask_classy import FlaskView, route
|
||||||
from flask import request, jsonify, render_template, redirect, url_for
|
from flask import request, jsonify, render_template, redirect, url_for
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
from bson.objectid import ObjectId
|
||||||
|
|
||||||
from pyfastocloud_models.utils.m3u_parser import M3uParser
|
from pyfastocloud_models.utils.m3u_parser import M3uParser
|
||||||
from app.common.service.forms import UploadM3uForm
|
from app.common.service.forms import UploadM3uForm
|
||||||
|
@ -9,6 +10,42 @@ from app.autofill.entry import M3uParseStreams, M3uParseVods
|
||||||
from pyfastocloud_models.utils.utils import is_valid_http_url
|
from pyfastocloud_models.utils.utils import is_valid_http_url
|
||||||
|
|
||||||
|
|
||||||
|
def _get_m3u_stream_by_id(sid: str):
|
||||||
|
try:
|
||||||
|
m3u = M3uParseStreams.objects.get({'_id': ObjectId(sid)})
|
||||||
|
except M3uParseStreams.DoesNotExist:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return m3u
|
||||||
|
|
||||||
|
|
||||||
|
def _get_m3u_stream_by_name(name: str):
|
||||||
|
try:
|
||||||
|
m3u = M3uParseStreams.objects.get({'name': name})
|
||||||
|
except M3uParseStreams.DoesNotExist:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return m3u
|
||||||
|
|
||||||
|
|
||||||
|
def _get_m3u_vod_by_id(sid: str):
|
||||||
|
try:
|
||||||
|
m3u = M3uParseVods.objects.get({'_id': ObjectId(sid)})
|
||||||
|
except M3uParseVods.DoesNotExist:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return m3u
|
||||||
|
|
||||||
|
|
||||||
|
def _get_m3u_vod_by_name(name: str):
|
||||||
|
try:
|
||||||
|
m3u = M3uParseVods.objects.get({'name': name})
|
||||||
|
except M3uParseVods.DoesNotExist:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return m3u
|
||||||
|
|
||||||
|
|
||||||
# routes
|
# routes
|
||||||
class M3uParseStreamsView(FlaskView):
|
class M3uParseStreamsView(FlaskView):
|
||||||
route_base = '/m3uparse_streams/'
|
route_base = '/m3uparse_streams/'
|
||||||
|
@ -24,7 +61,7 @@ class M3uParseStreamsView(FlaskView):
|
||||||
|
|
||||||
@route('/search/<sid>', methods=['GET'])
|
@route('/search/<sid>', methods=['GET'])
|
||||||
def search(self, sid):
|
def search(self, sid):
|
||||||
lines = M3uParseStreams.objects(id=sid)
|
lines = _get_m3u_stream_by_id(sid)
|
||||||
line = lines.first()
|
line = lines.first()
|
||||||
if line:
|
if line:
|
||||||
return jsonify(status='ok', line=line), 200
|
return jsonify(status='ok', line=line), 200
|
||||||
|
@ -48,7 +85,7 @@ class M3uParseStreamsView(FlaskView):
|
||||||
if len(title) > constants.MAX_STREAM_NAME_LENGTH:
|
if len(title) > constants.MAX_STREAM_NAME_LENGTH:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
line = M3uParseStreams.objects(name=title).first()
|
line = _get_m3u_stream_by_name(name=title)
|
||||||
if not line:
|
if not line:
|
||||||
line = M3uParseStreams(name=title)
|
line = M3uParseStreams(name=title)
|
||||||
|
|
||||||
|
@ -91,7 +128,7 @@ class M3uParseVodsView(FlaskView):
|
||||||
|
|
||||||
@route('/search/<sid>', methods=['GET'])
|
@route('/search/<sid>', methods=['GET'])
|
||||||
def search(self, sid):
|
def search(self, sid):
|
||||||
lines = M3uParseVods.objects(id=sid)
|
lines = _get_m3u_vod_by_id(sid)
|
||||||
line = lines.first()
|
line = lines.first()
|
||||||
if line:
|
if line:
|
||||||
return jsonify(status='ok', line=line), 200
|
return jsonify(status='ok', line=line), 200
|
||||||
|
@ -115,7 +152,7 @@ class M3uParseVodsView(FlaskView):
|
||||||
if len(title) > constants.MAX_STREAM_NAME_LENGTH:
|
if len(title) > constants.MAX_STREAM_NAME_LENGTH:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
line = M3uParseVods.objects(name=title).first()
|
line = _get_m3u_vod_by_name(title)
|
||||||
if not line:
|
if not line:
|
||||||
line = M3uParseVods(name=title)
|
line = M3uParseVods(name=title)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,6 @@ PREFERRED_URL_SCHEME = 'http'
|
||||||
BOOTSTRAP_SERVE_LOCAL = True
|
BOOTSTRAP_SERVE_LOCAL = True
|
||||||
SUBSCRIBERS_SUPPORT = False
|
SUBSCRIBERS_SUPPORT = False
|
||||||
EPG_SUPPORT = False
|
EPG_SUPPORT = False
|
||||||
META_SUPPORT = False
|
META_SUPPORT = True
|
||||||
EPG_IN_DIRECTORY = '~/epg/in'
|
EPG_IN_DIRECTORY = '~/epg/in'
|
||||||
OMDB_KEY = 'd8a1f487'
|
OMDB_KEY = 'd8a1f487'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue