Kaleido/scripts/verify_library_jump.py
Elijah 0c62d7414e
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m24s
Release Kaleido 0.3.0 with categories, alphabet jumps and audio preferences
2026-10-27 20:33:20 -07:00

76 lines
3.9 KiB
Python

"""Read-only D-pad checks for exact search, scoped genres and jumps beyond the first catalog page."""
import json,time,urllib.parse,urllib.request
from device import ROOT,adb,screenshot
from verify_ui import launch,key,text,focused,focus,snapshot,labels,wait,passed
LETTERS=['#']+list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
def first_at_letter(section,media_type,letter,genre=''):
cfg=dict(l.split('=',1) for l in (ROOT/'.env').read_text().splitlines() if '=' in l and not l.startswith('#'))
base=cfg['PLEX_SERVER_URL'].strip('"\'').rstrip('/')
headers={'X-Plex-Token':cfg['PLEX_TOKEN'].strip('"\''),'Accept':'application/json'}
def get(path,params):
request=urllib.request.Request(base+path+'?'+urllib.parse.urlencode(params),headers=headers)
with urllib.request.urlopen(request,timeout=30) as response:return json.load(response)['MediaContainer']
sections=get('/library/sections',{})['Directory']
section=next(s['key'] for s in sections if s['type']==media_type)
params={'type':'1' if media_type=='movie' else '2'}
if genre:
genres=get('/library/sections/'+section+'/genre',{})['Directory']
params['genre']=next(g['key'] for g in genres if g['title']==genre)
chars=get('/library/sections/'+section+'/firstCharacter',params)['Directory']
offset=0
for item in chars:
if item['title']==letter:break
offset+=item['size']
params.update({'sort':'titleSort:asc','X-Plex-Container-Start':offset,'X-Plex-Container-Size':1})
return get('/library/sections/'+section+'/all',params)['Metadata'][0]['title'],offset
def enter_rail():
for _ in range(10):
value=focus(snapshot())
if value in LETTERS:return value
key(22)
raise AssertionError('Right edge must enter letter bar; focus='+focus(snapshot()))
def jump(letter,expected):
current=enter_rail()
delta=LETTERS.index(letter)-LETTERS.index(current)
key(20 if delta>=0 else 19,abs(delta));focused(letter)
key(23)
# OK keeps the letter selected; Left explicitly enters the target title.
time.sleep(2);focused(letter);key(21);focused(expected)
key(23);wait(lambda r:any(s in labels(r) for s in ['Play','Resume','Seasons','Synopsis']),'Title details open')
key(4);focused(expected)
def section_check(tab,media_type):
launch();key(22,1 if tab=='Movies' else 2);focused(tab)
key(20);focused('Discover');key(22);focused('Library');key(23);focused('Library')
text('Z');screenshot('030-'+media_type+'-library')
key(20);key(20)
expected,offset=first_at_letter('',media_type,'S')
jump('S',expected)
passed(f'{tab} A-Z reaches S at absolute index {offset}, enters title and restores focus')
key(4);focused('Discover');key(22,2);focused('Categories');key(23)
# Genres are server-supplied and alphabetically ordered; move within the first row.
wait(lambda r:focus(r) not in ('','Categories'),'Category tile receives focus')
for _ in range(8):
if focus(snapshot())=='Animation':break
key(22)
focused('Animation');key(23);text('Animation ⌄');text('Z')
expected,offset=first_at_letter('',media_type,'S','Animation')
jump('S',expected)
screenshot('030-'+media_type+'-animation-jump')
key(4);focused('Animation');key(4);focused('Discover')
passed(f'{tab} Animation stays scoped and supports letter jump, details Back and category Back')
if __name__=='__main__':
for tab,kind in [('Movies','movie'),('TV Shows','show')]:section_check(tab,kind)
launch()
key(22,3);focused('Search');key(23);text('Search')
adb('shell','input','text','silo')
text('TV shows');key(66);focused('Silo')
# The first reachable result must be the exact series, never the unrelated movie row.
key(23);text('Seasons');screenshot('030-exact-silo-search')
key(4);focused('Silo');key(4);key(4)
passed('Silo search enters the exact series first and restores the result on Back')