Skip to content

Commit

Permalink
Plex-wide search in main NavBar
Browse files Browse the repository at this point in the history
  • Loading branch information
iBaa committed Apr 21, 2015
1 parent e27455e commit 7d35c20
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 0 deletions.
15 changes: 15 additions & 0 deletions PlexAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,21 @@ def getXMLFromMultiplePMS(ATV_udid, path, type, options={}):
if 'composite' in Playlist.attrib:
Playlist.set('composite', PMS_mark + getURL('', path, Playlist.get('composite')))
Server.append(Playlist)

for Video in XML.getiterator('Video'): # copy "Video" content, add PMS to links
key = Video.get('key') # absolute path
Video.set('key', PMS_mark + getURL('', path, key))
if 'thumb' in Video.attrib:
Video.set('thumb', PMS_mark + getURL('', path, Video.get('thumb')))
if 'parentKey' in Video.attrib:
Video.set('parentKey', PMS_mark + getURL('', path, Video.get('parentKey')))
if 'parentThumb' in Video.attrib:
Video.set('parentThumb', PMS_mark + getURL('', path, Video.get('parentThumb')))
if 'grandparentKey' in Video.attrib:
Video.set('grandparentKey', PMS_mark + getURL('', path, Video.get('grandparentKey')))
if 'grandparentThumb' in Video.attrib:
Video.set('grandparentThumb', PMS_mark + getURL('', path, Video.get('grandparentThumb')))
Server.append(Video)

root.set('size', str(len(root.findall('Server'))))

Expand Down
4 changes: 4 additions & 0 deletions assets/templates/PlexConnect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<title>{{TEXT(Channels)}}</title>
<url>{{URL(:/PMS(owned)/channels/all::PlexConnect=Channels_View)}}</url>
</navigationItem>{{CUT($channelview:CUT:=|Hide=CUT|Hide =)}}
<navigationItem id="Search">
<title>{{TEXT(Search)}}</title>
<url>{{URL(:/PMS(all)::PlexConnect=Search_EntryAllPMS)}}</url>
</navigationItem>
<navigationItem id="Settings">
<title>{{TEXT(Settings)}}</title>
<url>{{URL(:/::PlexConnect=Settings_Main)}}</url>
Expand Down
13 changes: 13 additions & 0 deletions assets/templates/Search/EntryAllPMS.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<atv>
<body>
<search id="plex-search">
<header>
<simpleHeader>
<title>{{TEXT(Search)}} PlexConnect</title>
</simpleHeader>
</header>
<baseURL>{{URL(:/PMS(all)/search::PlexConnect=Search_ResultsAllPMS&amp;type=4&amp;query=)}}</baseURL>
</search>
</body>
</atv>
142 changes: 142 additions & 0 deletions assets/templates/Search/ResultsAllPMS.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<atv>
<head>
<script src="{{URL(:/js/utils.js)}}" />
</head>

<body>
<searchResults id="searchResults">
<menu>
<sections>

<!-- Movies -->
<!-- servers -->
<__COPY__> <!--<menuSection>{{COPY}} somehow conflicts with </menuSection>{{CUT}}-->
{{COPY(Server:@main/size::0=|1=COPY)}}
<menuSection>

<header>
<horizontalDivider alignment="left">
<title>{{TEXT(Movies)}} &lt;{{VAL(name)}}{{VAL(local::0=, {{TEXT(remote)}}|0 =)}}&gt;</title>
</horizontalDivider>
</header>
<items>{{VAR(cut:NoKey:CUT)}} <!--this sets the var to CUT-->
<twoLineEnhancedMenuItem id="{{VAL(key)}}"
onPlay="atv.loadURL('{{URL(key:::PlexConnect=Play_Video&amp;PlexConnectRatingKey={{VAL(ratingKey)}})}}')"
onSelect="atv.loadURL('{{URL(key:::includeExtras=1&amp;PlexConnect=Movie_PrePlay{{VAL($fanart::Hide=|Show=_Fanart)}})}}')">
{{COPY(Video:type::=|movie=COPY|movie =)}}
{{VAR(cut:NoKey:)}} <!--this sets the var to None-->
<label>{{VAL(title)}}</label>
<image>{{IMAGEURL(thumb::384)}}</image>
<defaultImage>resource://Poster.png</defaultImage>
</twoLineEnhancedMenuItem>
</items>
</menuSection>{{CUT(#cut)}}
</__COPY__>

<!-- Shows -->
<!-- servers -->
<__COPY__> <!--<menuSection>{{COPY}} somehow conflicts with </menuSection>{{CUT}}-->
{{COPY(Server:@main/size::0=|1=COPY)}}
<menuSection>

<header>
<horizontalDivider alignment="left">
<title>{{TEXT(Shows)}} &lt;{{VAL(name)}}{{VAL(local::0=, {{TEXT(remote)}}|0 =)}}&gt;</title>
</horizontalDivider>
</header>
<items>{{VAR(cut:NoKey:CUT)}} <!--this sets the var to CUT-->
<twoLineEnhancedMenuItem id="{{VAL(key)}}"
onPlay="atv.loadURL('{{URL(key:::PlexConnect=TVShow_Season)}}')"
onSelect="atv.loadURL('{{URL(key:::PlexConnect=TVShow_Season)}}')">
{{COPY(Directory:type::=|show=COPY|show =)}}
{{VAR(cut:NoKey:)}} <!--this sets the var to None-->
<label>{{VAL(title)}}</label>
<image>{{IMAGEURL(thumb::384)}}</image>
<defaultImage>resource://Poster.png</defaultImage>
</twoLineEnhancedMenuItem>
</items>
</menuSection>{{CUT(#cut)}}
</__COPY__>

<!-- Episodes -->
<!-- servers -->
<__COPY__> <!--<menuSection>{{COPY}} somehow conflicts with </menuSection>{{CUT}}-->
{{COPY(Server:@main/size::0=|1=COPY)}}
<menuSection>

<header>
<horizontalDivider alignment="left">
<title>{{TEXT(Episodes)}} &lt;{{VAL(name)}}{{VAL(local::0=, {{TEXT(remote)}}|0 =)}}&gt;</title>
</horizontalDivider>
</header>
<items>{{VAR(cut:NoKey:CUT)}} <!--this sets the var to CUT-->
<twoLineEnhancedMenuItem id="{{VAL(key)}}"
onPlay="atv.loadURL('{{URL(key:::PlexConnect=Play_Video&amp;PlexConnectRatingKey={{VAL(ratingKey)}})}}')"
onSelect="atv.loadURL('{{URL(key:::includeExtras=1&amp;PlexConnect=Movie_PrePlay{{VAL($fanart::Hide=|Show=_Fanart)}})}}')">

This comment has been minimized.

Copy link
@roidy

roidy Apr 25, 2015

Collaborator

This is the incorrect preplay :( It should be:-

PlexConnect=TVShow_PrePlay.....

This comment has been minimized.

Copy link
@iBaa

iBaa Apr 25, 2015

Author Owner

Hm. You are right. I guess, somebody has to fix that. :-)

PS: This started as a plain copy from Results.xml, it's wrong there, too.

Edit: fixed both.

{{COPY(Video:type::=|episode=COPY|episode =)}}
{{VAR(cut:NoKey:)}} <!--this sets the var to None-->
<label>{{VAL(title)}}</label>
<label2>{{VAL(grandparentTitle)}}</label2>
<image>{{IMAGEURL(thumb::384)}}</image>
<defaultImage>resource://Poster.png</defaultImage>
</twoLineEnhancedMenuItem>
</items>
</menuSection>{{CUT(#cut)}}
</__COPY__>

<!-- Albums -->
<!-- servers -->
<__COPY__> <!--<menuSection>{{COPY}} somehow conflicts with </menuSection>{{CUT}}-->
{{COPY(Server:@main/size::0=|1=COPY)}}
<menuSection>

<header>
<horizontalDivider alignment="left">
<title>{{TEXT(Albums)}} &lt;{{VAL(name)}}{{VAL(local::0=, {{TEXT(remote)}}|0 =)}}&gt;</title>
</horizontalDivider>
</header>
<items>{{VAR(cut:NoKey:CUT)}} <!--this sets the var to CUT-->
<twoLineEnhancedMenuItem id="{{VAL(key)}}"
onPlay="atv.loadURL('{{URL(key:::PlexConnect=Music_Track)}}')"
onSelect="atv.loadURL('{{URL(key:::PlexConnect=Music_Track)}}')">
{{COPY(Directory:type::=|album=COPY|album =)}}
{{VAR(cut:NoKey:)}} <!--this sets the var to None-->
<label>{{VAL(title)}}</label>
<label2>{{VAL(parentTitle)}}</label2>
<image>{{IMAGEURL(thumb::384)}}</image>
<defaultImage>resource://Poster.png</defaultImage>
</twoLineEnhancedMenuItem>
</items>
</menuSection>{{CUT(#cut)}}
</__COPY__>

<!-- Artists -->
<!-- servers -->
<__COPY__> <!--<menuSection>{{COPY}} somehow conflicts with </menuSection>{{CUT}}-->
{{COPY(Server:@main/size::0=|1=COPY)}}
<menuSection>

<header>
<horizontalDivider alignment="left">
<title>{{TEXT(Artists)}} &lt;{{VAL(name)}}{{VAL(local::0=, {{TEXT(remote)}}|0 =)}}&gt;</title>
</horizontalDivider>
</header>
<items>{{VAR(cut:NoKey:CUT)}} <!--this sets the var to CUT-->
<twoLineEnhancedMenuItem id="{{VAL(key)}}"
onPlay="atv.loadURL('{{URL(key:::PlexConnect=Music_Directory)}}')"
onSelect="atv.loadURL('{{URL(key:::PlexConnect=Music_Directory)}}')">
{{COPY(Directory:type::=|artist=COPY|artist =)}}
{{VAR(cut:NoKey:)}} <!--this sets the var to None-->
<label>{{VAL(title)}}</label>
<image>{{IMAGEURL(thumb::384)}}</image>
<defaultImage>resource://Poster.png</defaultImage>
</twoLineEnhancedMenuItem>
</items>
</menuSection>{{CUT(#cut)}}
</__COPY__>

</sections>
</menu>
</searchResults>
</body>
</atv>

6 comments on commit 7d35c20

@roidy
Copy link
Collaborator

@roidy roidy commented on 7d35c20 Apr 22, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umm.. doesn't this now make the "Search" item under library obsolete? Do we really need search in two different places?

Also can we please remove the server name if there is only one, like we do for the library view.

@iBaa
Copy link
Owner Author

@iBaa iBaa commented on 7d35c20 Apr 23, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Search" item under library

Hm, I would keep the server based search. Not sure if it's needed, but the overrall search can get very crowded with mulitple servers/results.

remove server name

Yep, I guess.

Another thing I thought about - pre-select the type of media you are looking for. Like Select&Hold on Search, showing a sub-menu with Movie, Show, Episode, ... to only request this kind from PMS. Not quite sure how to implement it, but it would be a way to reduce useless (as in not needed right now) clutter as well.

@roidy
Copy link
Collaborator

@roidy roidy commented on 7d35c20 Apr 23, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I would keep the server based search.

But for a lot of users, me included, who only have one server it's redundant. Now we have two searches that do exactly the same thing, kind of pointless :(

If you really don't want to get rid of the search in library then at least add a setting to hide the "Search" in the navbar so users with a single server don't have two searches that do the same thing.

Another thing I thought about - pre-select the type of media you are looking for. Like Select&Hold on Search, showing a sub-menu with Movie, Show, Episode, ...

Unfortunately you can't do a onHoldSelect or any kind of keypress query on a navbar item :(

@wahlmanj
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just add a option to hide the Search tab like the rest of the tabs already have? Also for users with 25+ shared/owned/remote servers this is nice ;)

@roidy
Copy link
Collaborator

@roidy roidy commented on 7d35c20 Apr 24, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just add a option to hide the Search tab like the rest of the tabs already have?

Good idea.... no wait.... didn't I just say the same thing ;)

@wahlmanj
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes you did. Don't know how I missed that...

Please sign in to comment.