Damianonymous / MFCRecorder

16 stars 13 forks source link

Recording doesn't start, missing models from online? #5

Open ipkpjersi opened 5 years ago

ipkpjersi commented 5 years ago

Hi,

My wanted.json is formatted properly but it never starts recording:

another run 2019-11-04 23:56:18.987819

For some reason, it says 1089 models online and it's like the models I put in wanted.json aren't online because I have mfc-node setup and it says 1320 models online.

Thanks.

Jprnp commented 3 years ago

I found the reason and wrote a fix for it.

In your classes/models.py:

def get_online_models():
    '''returns a dictionary of all online models in free chat'''
    server_config = requests.get(SERVER_CONFIG_URL).json()
    servers = list(server_config['h5video_servers'].keys())
    servers.extend(list(server_config['ngvideo_servers'].keys()))
    servers.extend(list(server_config['wzext_servers'].keys()))
    servers.extend(list(server_config['wzobs_servers'].keys()))
    models = {}

In your classes/recording.py:

class RecordingThread(threading.Thread):
    '''thread for recording a MFC session'''
    URL_TEMPLATE1 = "hlsvariant://https://edgevideo.myfreecams.com/hls/NxServer/{srv}/ngrp:mfc_a_{id}.f4v_mobile/playlist.m3u8"
    URL_TEMPLATE2 = "hlsvariant://http://video{srv}.myfreecams.com:1935/NxServer/ngrp:mfc_{id}.f4v_mobile/playlist.m3u8"

...

    @property
    def stream(self):
        '''returns a dictionary with available streams'''
        streams = {} #not sure this is needed for the finally to work
        try_count = 0
        template = ""
        no_to_subtract = 0
        while len(streams) == 0 and try_count < 4:
            try:
                if try_count == 0:
                    template = self.URL_TEMPLATE1
                    no_to_subtract = 700
                elif try_count == 1:
                    template = self.URL_TEMPLATE1
                    no_to_subtract = 500
                elif try_count == 2:
                    template = self.URL_TEMPLATE2
                    no_to_subtract = 700
                elif try_count == 3:
                    template = self.URL_TEMPLATE2
                    no_to_subtract = 500

                streams = livestreamer.Livestreamer().streams(template.format(
                    id=int(self.session['uid']) + 100_000_000,
                    srv=int(self.session['camserv']) - no_to_subtract))
            except:
                try_count += 1

        return streams.get('best')

@Damianonymous, please validate and, if possible, implement this on your code.