askvictor wrote: 
> I'm happy to make some changes; I used to program Perl (some 10 years
> ago now so I've forgotten some bits but the basics are still there). The
> main thing getting in my way is understanding the LMS framework and how
> the plugin interacts with youtube.

Perfect. Then look at the file ProtocolHandler, a function named
"sysread". This is called by LMS everytime it needs audio data. Here
you'll find a piece of codec

Code:
--------------------
    
                Slim::Networking::SimpleAsyncHTTP->new(
                        sub {
                                $v->{'inBuf'} .= $_[0]->content;
                                $v->{'fetching'} = 0;
                                if ( $props->{'segmentURL'} ) {
                                        $v->{'streaming'} = 0 if $v->{'offset'} 
== @{$props->{'segmentURL'}};
                                        main::DEBUGLOG && $log->is_debug && 
$log->debug("got chunk $v->{'offset'} length: ", length $_[0]->content, " for 
$url");
                                } else {
                                        main::DEBUGLOG && $log->is_debug && 
$log->debug("got chunk length: ", length $_[0]->content, " from ", $v->{offset} 
- DATA_CHUNK, " for $url");
                                        $v->{'streaming'} = 0 if 
length($_[0]->content) < DATA_CHUNK;
                                }               
                        },
  
                        sub {
                                if (main::DEBUGLOG && $log->is_debug) {
                                        $log->debug("error fetching $url")
                                }
                                # only log error every x seconds - it's too 
noisy for regular use
                                elsif (time() > $nextWarning) {
                                        $log->warn("error fetching $url");
                                        $nextWarning = time() + 10;
                                }
  
                                $v->{'inBuf'} = '';
                                $v->{'fetching'} = 0;
                        }, 
                        
                )->get($url, @range);
  
--------------------


Just replace get($url, @range) by get($url, 'User-Agent' => XXXX,
@range) where XXXX is the user-agent you want to try. For example, my
chrome is

Code:
--------------------
    
  Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like 
Gecko) Chrome/70.0.3538.77 Safari/537.36
  
--------------------

Then stop and restart LMS.

Just a quick note if you want to understand a bit more the LMS framework
and my code: LMS runs in a cooperative mode, so no code should be
blocking, typically a GET shall not use LWP, but use Async. So sysread,
when called, process as much audio as possible from its input buffer and
returns it in an output buffer. If that output buffer reaches a low
watermark, it does a new HTTP GET for another chunk. That GET is made
using Async, so the result is received later, asynchronously and all it
does is filling the input buffer. Next call to sysread will use that
newly filled input buffer



LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos
PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000,
ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi
B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010,
AppleTV 4, Airport Express, GGMM E5
------------------------------------------------------------------------
philippe_44's Profile: http://forums.slimdevices.com/member.php?userid=17261
View this thread: http://forums.slimdevices.com/showthread.php?t=105840

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to