Integrate native decoder TV and internet EPG artwork with Jellyfin 12.2
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""Hide the duplicate home tile without removing the provider or recording files."""
|
||||
import datetime,json,os,pathlib,sqlite3,urllib.request
|
||||
db=sqlite3.connect('file:/var/lib/jellyfin/data/jellyfin.db?mode=ro',uri=True)
|
||||
key=db.execute('SELECT AccessToken FROM ApiKeys ORDER BY Id LIMIT 1').fetchone()[0];db.close()
|
||||
def api(path,data=None):
|
||||
request=urllib.request.Request('http://127.0.0.1:8096'+path,headers={'Authorization':'MediaBrowser Token="'+key+'", Client="DecoderIntegration", Device="Maintenance", DeviceId="decoder-maintenance", Version="7"','Content-Type':'application/json'},data=None if data is None else json.dumps(data).encode())
|
||||
body=urllib.request.urlopen(request,timeout=30).read();return json.loads(body) if body else None
|
||||
channel=next(c for c in api('/Channels')['Items'] if c['Name']=='Enigma2 Recordings')
|
||||
users=api('/Users');backup={u['Id']:u['Configuration'] for u in users}
|
||||
folder=pathlib.Path('/var/lib/jellyfin/decoder-plugin-backups');folder.mkdir(mode=0o700,exist_ok=True)
|
||||
file=folder/('home-exclusions-'+datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%dT%H%M%SZ')+'.json')
|
||||
fd=os.open(file,os.O_WRONLY|os.O_CREAT|os.O_EXCL,0o600)
|
||||
with os.fdopen(fd,'w') as output:json.dump(backup,output)
|
||||
for user in users:
|
||||
config=dict(user['Configuration'])
|
||||
for field in ['MyMediaExcludes','LatestItemsExcludes']:
|
||||
ids=config.get(field,[])
|
||||
if channel['Id'].replace('-','').lower() not in [x.replace('-','').lower() for x in ids]:config[field]=ids+[channel['Id']]
|
||||
api('/Users/'+user['Id']+'/Configuration',config)
|
||||
check=api('/Users/'+user['Id'])['Configuration']
|
||||
assert channel['Id'] in check['MyMediaExcludes'] and channel['Id'] in check['LatestItemsExcludes']
|
||||
print(json.dumps({'home_tile_hidden_for_users':len(users),'provider_retained':True,'backup':str(file)}))
|
||||
Reference in New Issue
Block a user