From da0e05384a0e49ce92fe6d692eb0b5267cd0a356 Mon Sep 17 00:00:00 2001 From: topilski Date: Tue, 18 Feb 2020 10:55:09 -0500 Subject: [PATCH] Review --- app/autofill/entry.py | 14 ++++++++++++++ app/autofill/view.py | 10 ++++------ app/config/config.py | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/autofill/entry.py b/app/autofill/entry.py index e8a36ff..3b7b6a5 100644 --- a/app/autofill/entry.py +++ b/app/autofill/entry.py @@ -7,6 +7,13 @@ class M3uParseStreams(MongoModel): class Meta: collection_name = 'm3uparse_streams' + def to_dict(self) -> dict: + return {'id': str(self.id), 'name': self.name, 'epgid': self.tvg_id, 'logo': self.tvg_logo, 'group': self.group} + + @property + def id(self): + return self.pk + name = fields.CharField(max_length=constants.MAX_STREAM_NAME_LENGTH, min_length=constants.MIN_STREAM_NAME_LENGTH, required=True) @@ -19,6 +26,13 @@ class M3uParseVods(MongoModel): class Meta: collection_name = 'm3uparse_vods' + def to_dict(self) -> dict: + return {'id': str(self.id), 'name': self.name, 'logo': self.tvg_logo, 'group': self.group} + + @property + def id(self): + return self.pk + name = fields.CharField(max_length=constants.MAX_STREAM_NAME_LENGTH, min_length=constants.MIN_STREAM_NAME_LENGTH, required=True) diff --git a/app/autofill/view.py b/app/autofill/view.py index 30d9c14..0fc3f91 100644 --- a/app/autofill/view.py +++ b/app/autofill/view.py @@ -61,10 +61,9 @@ class M3uParseStreamsView(FlaskView): @route('/search/', methods=['GET']) def search(self, sid): - lines = _get_m3u_stream_by_id(sid) - line = lines.first() + line = _get_m3u_stream_by_id(sid) if line: - return jsonify(status='ok', line=line), 200 + return jsonify(status='ok', line=line.to_dict()), 200 return jsonify(status='failed', error='Not found'), 404 @@ -128,10 +127,9 @@ class M3uParseVodsView(FlaskView): @route('/search/', methods=['GET']) def search(self, sid): - lines = _get_m3u_vod_by_id(sid) - line = lines.first() + line = _get_m3u_vod_by_id(sid) if line: - return jsonify(status='ok', line=line), 200 + return jsonify(status='ok', line=line.to_dict()), 200 return jsonify(status='failed', error='Not found'), 404 diff --git a/app/config/config.py b/app/config/config.py index dcd5498..f65454b 100644 --- a/app/config/config.py +++ b/app/config/config.py @@ -5,6 +5,6 @@ PREFERRED_URL_SCHEME = 'http' BOOTSTRAP_SERVE_LOCAL = True SUBSCRIBERS_SUPPORT = False EPG_SUPPORT = False -META_SUPPORT = True +META_SUPPORT = False EPG_IN_DIRECTORY = '~/epg/in' OMDB_KEY = 'd8a1f487'