Closed ElFishi closed 3 months ago
Thanks for your detailed description. I have the same problem here on my end. I thought i am the only one who has this problem.
Logitech Media Server-Status Logitech Media Server Version: 8.4.1 - 1708338002 @ Tue Feb 20 03:02:42 CET 2024 Hostname: LMS IP-Adresse des Servers: 192.168.2.25 Server-HTTP-Portnummer: 9002 Betriebssystem: Debian (Docker) - DE - utf8 Plattformarchitektur: x86_64-linux Datenbankversion: SQLite Anzahl erkannter Player: 3
Perl- und Modulversionen Perl-Version: 5.32.1 - x86_64-linux-gnu-thread-multi Audio::Scan: 1.06 DBD::SQLite: 1.58 (sqlite 3.22.0) IO::Socket::SSL: 2.069 Mozilla::CA: Net::SSLeay: 1.88 - OpenSSL 1.1.1w 11 Sep 2023
I run this little script in the background as workaround. Could be more finely tuned, but works.
#!/usr/bin/env python
import time
import requests
import json
import logging
from datetime import datetime
import os, stat
# Configure logging to write messages to a file
logging.basicConfig(
filename = 'skipLMS.log',
level = logging.INFO,
format = '%(asctime)s %(levelname).1s %(message)s',
datefmt = '%Y-%m-%d %H:%M:%S'
)
ServerLMS = "http://lmsserver:9000/jsonrpc.js"
logfile = "/var/log/squeezeboxserver/server.log"
trigger = "start offset 403 Forbidden"
'''
References
http://www.dabeaz.com/generators/Generators.pdf pp 75
https://stackoverflow.com/questions/62036007/rotate-reopen-file-in-python3-when-signal-is-received
'''
def follow(filename):
while True:
with open(filename,'r') as thefile:
f_ino = os.stat(logfile)[stat.ST_INO]
f_dev = os.stat(logfile)[stat.ST_DEV]
logging.info(f"Follow {filename}, ino {f_ino}, dev {f_dev}")
thefile.seek(0, 2) # End-of-file
while True:
line = thefile.readline()
try:
if (os.stat(logfile)[stat.ST_INO] != f_ino or
os.stat(logfile)[stat.ST_DEV] != f_dev):
logging.info("file ino or dev has changed.")
break
except OSError:
pass
if not line:
time.sleep(1)
continue
yield line
time.sleep(2)
def execute (player,cmd):
data = { 'id': 1, 'method': 'slim.request', 'params': [player,cmd]}
response = requests.get(ServerLMS, data=json.dumps(data)).json()
result = response['result']
return result
def skip_song():
count = execute("",["player", "count", "?"])
count = count['_count']
players = execute('', ['players','0', count])
players = players['players_loop']
logging.info( f"Found players: { ', '.join(player['name'] for player in players) }" )
for player in players:
if player['isplaying']:
status = execute(player['playerid'],['status','-',1,''])
logging.info(f"{player['name']} is playing { status['current_title']}: {status['time']:.1f} / {status['duration']}")
time_elapsed = status['time']
timeleft = status['duration'] - time_elapsed
logging.info(f"Time left: {timeleft:.1f}")
if timeleft < 9.0:
time.sleep(timeleft)
execute(player['playerid'],['playlist','index','+1'])
logging.info("player told to skip.")
else:
time.sleep(2)
status = execute(player['playerid'],['status','-',1,''])
if status['time'] - time_elapsed < 1:
execute(player['playerid'],['playlist','index','+1'])
logging.info("player told to skip.")
logging.info("SkipLMS: Follow LMS server.log and skip song if playlist is stuck at the end of a song.")
loglines = follow(logfile)
for line in loglines:
if trigger in line:
skip_song()
logging.debug(line.replace("\n",""))
I've released 0.212 which make LMS fail when such issue occurs and it should move to next track automatically
I am closing this as 212 likely solves the issue. I've been running Youtube/LMS for two weeks now and maaaayyyybe had one stop.
In order for this forum post not to be buried I am posting my issue her again:
I have a problem with playing long playlists in YT: In irregular intervals, probably btn 10 to 100 songs LMS stops playing the playlist:
One song has fully finished, LMS still shows the pause sign as if it was still playing, and the time elapsed is either at the length of the song or flipping between one second before and the end. The corresponding long entries look like this:
Playback stops after
__ANON__ (154) starting from offset
and when I press >> (fwd) the next song plays and the log continues with
canDoAction (91) action=stop
Since I started tracking the issue every stalled playlist playback by the YouTube plugin was associated with the same log entries