Пример #1
0
def safe_delete_stream(stream: IStream):
    if stream:
        from pyfastocloud_models.subscriber.entry import Subscriber
        subscribers = Subscriber.objects.all()
        for subscriber in subscribers:
            subscriber.remove_official_stream(stream)
            subscriber.remove_official_vod(stream)
            subscriber.remove_official_catchup(stream)
        for catchup in stream.parts:
            safe_delete_stream(catchup)
        stream.delete()
Пример #2
0
    def update_stream(self, stream: IStream):
        if not stream:
            return None

        stream.save(self._settings)
        stream_object = self.find_stream_by_id(stream.id)
        if not stream_object:
            return None

        stream_object._stream = stream
        self._notify_stream_updated(stream_object)
Пример #3
0
 def update_entry(self, entry: IStream) -> IStream:
     entry.tvg_id = self.tvg_id.data
     entry.name = self.name.data
     entry.tvg_name = self.tvg_name.data
     entry.tvg_logo = self.tvg_logo.data
     entry.group = self.group.data
     entry.price = self.price.data
     entry.visible = self.visible.data
     entry.iarc = self.iarc.data
     entry.view_count = self.view_count.data
     entry.output = self.output.data
     # for entry in self.extra_config_fields.entries:
     # entry.extra_config_fields = self.extra_config_fields.get_data()
     return entry
Пример #4
0
 def remove_own_vod_by_id(self, sid: ObjectId):
     vod = IStream.get_by_id(sid)
     if vod:
         for vod in self.vod:
             if vod.private and vod.sid == sid:
                 self.vod.remove(vod)
         vod.delete()
Пример #5
0
 def remove_own_stream_by_id(self, sid: ObjectId):
     stream = IStream.get_by_id(sid)
     if stream:
         for stream in self.streams:
             if stream.sid == sid:
                 self.stream.remove(stream)
         stream.delete()
Пример #6
0
    def __convert_stream(self, stream: IStream) -> IStreamObject:
        if not stream:
            return

        stream_type = stream.get_type()
        if stream_type == constants.StreamType.PROXY:
            return ProxyStreamObject(stream, self._settings)
        elif stream_type == constants.StreamType.VOD_PROXY:
            return ProxyVodStreamObject(stream, self._settings)
        elif stream_type == constants.StreamType.RELAY:
            return RelayStreamObject(stream, self._settings, self._client)
        elif stream_type == constants.StreamType.ENCODE:
            return EncodeStreamObject(stream, self._settings, self._client)
        elif stream_type == constants.StreamType.TIMESHIFT_PLAYER:
            return TimeshiftPlayerStreamObject(stream, self._settings,
                                               self._client)
        elif stream_type == constants.StreamType.TIMESHIFT_RECORDER:
            return TimeshiftRecorderStreamObject(stream, self._settings,
                                                 self._client)
        elif stream_type == constants.StreamType.CATCHUP:
            return CatchupStreamObject(stream, self._settings, self._client)
        elif stream_type == constants.StreamType.TEST_LIFE:
            return TestLifeStreamObject(stream, self._settings, self._client)
        elif stream_type == constants.StreamType.VOD_RELAY:
            return VodRelayStreamObject(stream, self._settings, self._client)
        elif stream_type == constants.StreamType.VOD_ENCODE:
            return VodEncodeStreamObject(stream, self._settings, self._client)
        elif stream_type == constants.StreamType.COD_RELAY:
            return CodRelayStreamObject(stream, self._settings, self._client)
        elif stream_type == constants.StreamType.COD_ENCODE:
            return CodEncodeStreamObject(stream, self._settings, self._client)
        elif stream_type == constants.StreamType.EVENT:
            return EventStreamObject(stream, self._settings, self._client)
        else:
            return None  #
Пример #7
0
    def play(self, sid):
        stream = IStream.objects(id=sid).first()
        if stream:
            return Response(stream.generate_playlist(),
                            mimetype='application/x-mpequrl'), 200

        return jsonify(status='failed'), 404
Пример #8
0
    def play(self, sid):
        stream = IStream.get_by_id(ObjectId(sid))
        if stream:
            return Response(stream.generate_playlist(),
                            mimetype='application/x-mpequrl'), 200

        return jsonify(status='failed'), 404
Пример #9
0
def is_catchup(stream: IStream):
    if not stream:
        return False
    if not stream.visible:
        return False
    stream_type = stream.get_type()
    return stream_type == constants.StreamType.CATCHUP
Пример #10
0
def is_vod_stream(stream: IStream):
    if not stream:
        return False
    if not stream.visible:
        return False
    stream_type = stream.get_type()
    return stream_type == constants.StreamType.VOD_PROXY or stream_type == constants.StreamType.VOD_RELAY or \
           stream_type == constants.StreamType.VOD_ENCODE
Пример #11
0
def is_live_stream(stream: IStream):
    if not stream:
        return False
    if not stream.visible:
        return False
    stream_type = stream.get_type()
    return stream_type == constants.StreamType.PROXY or stream_type == constants.StreamType.RELAY or \
           stream_type == constants.StreamType.ENCODE or stream_type == constants.StreamType.TIMESHIFT_PLAYER or \
           stream_type == constants.StreamType.COD_RELAY or stream_type == constants.StreamType.COD_ENCODE or \
           stream_type == constants.StreamType.EVENT
Пример #12
0
 def update_stream(self, stream: IStream):
     stream.save()
     stream_object = self.find_stream_by_id(stream.id)
     if stream_object:
         stream_object.stable()
Пример #13
0
 def fill_defaults(stream: IStream):
     stream.tvg_logo = url_for('static', filename='images/unknown_channel.png', _external=True)
     if hasattr(stream, 'trailer_url'):
         stream.trailer_url = url_for('static', filename='media/unknown_trailer.m3u8', _external=True)
Пример #14
0
 def __init_stream_runtime_fields(self, stream: IStream):
     stream.set_server_settings(self._settings)
#!/usr/bin/env python3
import argparse
import os
import sys
from mongoengine import connect

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

PROJECT_NAME = 'parse_streams_collection'

from pyfastocloud_models.stream.entry import IStream

if __name__ == '__main__':
    parser = argparse.ArgumentParser(prog=PROJECT_NAME,
                                     usage='%(prog)s [options]')
    parser.add_argument('--mongo_uri',
                        help='MongoDB credentials',
                        default='mongodb://localhost:27017/iptv')

    argv = parser.parse_args()

    mongo = connect(host=argv.mongo_uri)
    if mongo:
        streams = IStream.objects()
        f = open("out.m3u", "w")
        f.write('#EXTM3U\n')
        idx = 0
        for stream in streams:
            f.write(stream.generate_input_playlist(False))
        f.close()
Пример #16
0
 def make_entry(self) -> IStream:
     return self.update_entry(IStream())
Пример #17
0
 def remove_official_vod_by_id(self, sid: ObjectId):
     original_stream = IStream.get_by_id(sid)
     self.remove_official_vod(original_stream)
Пример #18
0
 def add_stream_by_id(self, sid: ObjectId) -> IStreamObject:
     stream = IStream.get_by_id(sid)
     return self.add_stream(stream)
Пример #19
0
 def remove_stream(self, stream: IStream):
     if stream:
         self.streams.remove(stream)
         stream.delete()
Пример #20
0
 def remove_official_catchup_by_id(self, sid: ObjectId):
     original_stream = IStream.get_stream_by_id(sid)
     self.remove_official_catchup(original_stream)