Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by words option for Channels/Movies/Series #65

Open
hect-dpr opened this issue Dec 8, 2020 · 13 comments
Open

Search by words option for Channels/Movies/Series #65

hect-dpr opened this issue Dec 8, 2020 · 13 comments

Comments

@hect-dpr
Copy link

hect-dpr commented Dec 8, 2020

Hey @clefebvre,
Great App. Would be better if a quick search channel option across categories is present, so that we can quickly search and find the right available channel. Similarly for movies, VOD etc.

Here's an immature attempt for current active_provider channels:

diff --git a/usr/lib/hypnotix/hypnotix.py b/usr/lib/hypnotix/hypnotix.py
index d335f69..5e0c57e 100755
--- a/usr/lib/hypnotix/hypnotix.py
+++ b/usr/lib/hypnotix/hypnotix.py
@@ -109,8 +109,8 @@ class MainWindow():
 
         # Create variables to quickly access dynamic widgets
         self.generic_channel_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("/usr/share/hypnotix/generic_tv_logo.png", 22, 22)
-        widget_names = ["headerbar", "status_label", "status_bar", "sidebar", "go_back_button", "channels_box", \
-            "provider_button", "preferences_button", \
+        widget_names = ["headerbar", "status_label", "status_bar", "sidebar", "go_back_button", "search_button", "search_bar", \
+            "channels_box", "provider_button", "preferences_button", \
             "mpv_drawing_area", "stack", "fullscreen_button", \
             "provider_ok_button", "provider_cancel_button", \
             "name_entry", "path_label", "path_entry", "browse_button", "url_label", "url_entry", \
@@ -157,6 +157,8 @@ class MainWindow():
         self.movies_button.connect("clicked", self.show_groups, MOVIES_GROUP)
         self.series_button.connect("clicked", self.show_groups, SERIES_GROUP)
         self.go_back_button.connect("clicked", self.on_go_back_button)
+        self.search_button.connect("clicked", self.on_search_button)
+        self.search_bar.connect("activate", self.on_search_button)
 
         self.stop_button.connect("clicked", self.on_stop_button)
         self.pause_button.connect("clicked", self.on_pause_button)
@@ -304,14 +306,16 @@ class MainWindow():
             else:
                 self.show_vod(self.active_provider.series)
 
-    def show_channels(self, channels):
-        self.navigate_to("channels_page")
+    def show_channels(self, channels, search=False):
+        self.navigate_to("channels_page", '', search)
         if self.content_type == TV_GROUP:
             self.sidebar.show()
             logos_to_refresh = []
             for child in self.channels_flowbox.get_children():
                 self.channels_flowbox.remove(child)
             for channel in channels:
+                if search and self.search_bar.get_text() not in channel.name.lower():
+                    continue 
                 button = Gtk.Button()
             self.sidebar.show()
             logos_to_refresh = []
             for child in self.channels_flowbox.get_children():
                 self.channels_flowbox.remove(child)
             for channel in channels:
+                if search and self.search_bar.get_text() not in channel.name.lower():
+                    continue 
                 button = Gtk.Button()
                 button.connect("clicked", self.on_channel_button_clicked, channel)
                 label = Gtk.Label()
@@ -469,13 +473,19 @@ class MainWindow():
         self.navigate_to(self.back_page)
         if self.active_channel != None:
             self.playback_bar.show()
+    
+    def on_search_button(self, widget):
+        self.show_channels(self.active_provider.channels, True)
+
 
     @idle_function
-    def navigate_to(self, page, name=""):
+    def navigate_to(self, page, name="", search=False):
         self.go_back_button.show()
+        self.search_button.show()
         self.fullscreen_button.hide()
 
     @idle_function
-    def navigate_to(self, page, name=""):
+    def navigate_to(self, page, name="", search=False):
         self.go_back_button.show()
+        self.search_button.show()
         self.fullscreen_button.hide()
         self.stack.set_visible_child_name(page)
         provider = self.active_provider
+
         if page == "landing_page":
             self.back_page = None
             self.headerbar.set_title("Hypnotix")
@@ -567,6 +577,9 @@ class MainWindow():
             self.back_page = "providers_page"
             self.headerbar.set_title("Hypnotix")
             self.headerbar.set_subtitle(_("Reset providers"))
+        
+        if search:
+            self.headerbar.set_subtitle(_("Search > %s" % self.search_bar.get_text()))
 
     def open_keyboard_shortcuts(self, widget):
         gladefile = "/usr/share/hypnotix/shortcuts.ui"
diff --git a/usr/share/hypnotix/hypnotix.ui b/usr/share/hypnotix/hypnotix.ui
index 2201b22..56182f0 100644
--- a/usr/share/hypnotix/hypnotix.ui
+++ b/usr/share/hypnotix/hypnotix.ui
@@ -43,6 +43,43 @@
             </child>
           </object>
         </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkButton" id="search_button">
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon_name">system-search-symbolic</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkEntry" id="search_bar">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="valign">center</property>
+            <property name="hexpand">True</property>
+            <property name="placeholder_text" translatable="yes">Search</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">0</property>
+          </packing>
+        </child>
         <child>
           <object class="GtkBox">
             <property name="visible">True</property>

Thanks

@0xrin1
Copy link

0xrin1 commented Dec 11, 2020

Hey @hect-dpr I was looking for this exact feature and was really happy to see that someone got a start on it.

If possible, could you please submit this as a pull request (by creating your own fork first, making the change there, and then opening a pull request against the master branch here [I see no develop branch]) so that I can try out + work on these changes too?

I tried opening the PR myself with the diff you pasted but there's a part in your comment that doesn't line up with what I'm seeing in my source (master branch, pulled today).

Thanks!

@hect-dpr
Copy link
Author

Here you go @dilutedh2o for active_provider.channels: https://github.com/hect-dpr/hypnotix/tree/dev. I don't think its mature and general enough for a PR.

@antrrax
Copy link

antrrax commented Dec 14, 2020

This search option for movies and series is very interesting and would be a very useful function

@esaumell
Copy link

esaumell commented Apr 4, 2021

@clefebvre Great to have IPTV on Mint in a simple application. IMHO a search box should be there.

@lulol
Copy link
Contributor

lulol commented Aug 4, 2021

@hect-dpr for #157 I tried to merge your old code from your repo to my fork of this repo to keep the git history of your changes but with github's interface have not been capable to make it work, so had to make the changes directly for the pull request.

@0xrin1
Copy link

0xrin1 commented Aug 4, 2021

@lulol dude you are a hero, that works really well

I'm not a maintainer but that has my +1

@0xrin1
Copy link

0xrin1 commented Aug 4, 2021

Actually I just found a bug 😟

If you search something, then clear the search bar and hit enter the UI stops reacting

@lulol
Copy link
Contributor

lulol commented Aug 4, 2021

Hmmm. @dilutedh2o I found that problem before but added a check in on_search_button() to ignore empty strings to avoid it. Then to see all the channels again you must use the back button.

There is an explicit check in L532 for an empty search box. But seems that it may not be enough.

if self.search_bar.get_text() != "":

But with this check in place I've tried several times to trigger this condition on my system and I'm unable to reproduce the problem. Don't know how you managed to skip the empty string test, and not sure what the root cause is.


EDIT: BTW the credit goes to @hect-dpr that is who wrote the original patch. I only adapted it and enhanced the text match.

@lulol
Copy link
Contributor

lulol commented Aug 4, 2021

May be removing any leading/trailing whitespace from the search text could help.

For very large playlists may look that the ui has frozen if the search string is just a space since for some reason seems that it takes a long time to rebuild a list with (almost) all of the channels.

clefebvre pushed a commit that referenced this issue Nov 23, 2021
* Add search box is toggled with seach button

* Add Search is a toggle button

* Add Search is a toggle button

* Add shortcut for search box

* Rename on_search_button function for consistency

* Fix find menu iten icon

* Avoid repeating searches

This is to minimize the chance of an issue first [reported](#65 (comment)) by @dilutedh2o for huge lists.

Triggering multiple searches before the channels FlowBox rendering is completed may result in Hypnotix being unresponsive for several minutes. Also CTRL-C doesn't work. Have not been able to trace the root cause. May be related to network failures of pending channel logo downloads flooding the home router dropping traffic?

* Add Search box grayed out while filtering

* Change channel search method

Use Gtk.FlowBox.set_filter_func() instead of destroying and recreating Gtk.FlowBox childs.

* Fix headerbar AttributeError searching mixed content lists

* Avoid race condition playing local content

# https://github.com/jaseg/python-mpv#pygobject-embedding
# Must be created >after< the widget is shown, else property 'window' will be None

Wait for window to get ready before retrieving properties and playing content to avoid it to fail with local content.

* Add files via upload

* Add files via upload

* Add files via upload

* Stop waiting for widget window when there are pending events
clefebvre pushed a commit that referenced this issue Nov 23, 2021
* Add search box is toggled with seach button

* Add Search is a toggle button

* Add Search is a toggle button

* Add shortcut for search box

* Rename on_search_button function for consistency

* Fix find menu iten icon

* Avoid repeating searches

This is to minimize the chance of an issue first [reported](#65 (comment)) by @dilutedh2o for huge lists.

Triggering multiple searches before the channels FlowBox rendering is completed may result in Hypnotix being unresponsive for several minutes. Also CTRL-C doesn't work. Have not been able to trace the root cause. May be related to network failures of pending channel logo downloads flooding the home router dropping traffic?

* Add Search box grayed out while filtering

* Change channel search method

Use Gtk.FlowBox.set_filter_func() instead of destroying and recreating Gtk.FlowBox childs.

* Fix headerbar AttributeError searching mixed content lists
@dreizweins
Copy link

So, I'm quite a noob in terms of Linux.. How do I add this search bar to Hypnotix?

@lulol
Copy link
Contributor

lulol commented Aug 19, 2022

@dreizweins The search function is already available since version 2.1 and instalable from the LM repos.

The .deb 1.1 release available on Github for download is obsolete.

If you are using other linux distro or a not so recent LM, I'm afraid that you may need to download the zip and install the files manually.

@dreizweins
Copy link

@dreizweins The search function is already available since version 2.1 and instalable from the LM repos.

The .deb 1.1 release available on Github for download is obsolete.

If you are using other linux distro or a not so recent LM, I'm afraid that you may need to download the zip and install the files manually.

how do i install the files manually? :D

@AnVaimpir
Copy link

AnVaimpir commented Jan 20, 2023

Hi,

I have v3.2 installed.
When will search across TV and Movies be available?
This would be an amazing feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants