Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Diff

Differences From Artifact [f68e153942]:

To Artifact [31aa4c2365]:

  • Executable file st2.py — part of check-in [ac8632bc29] at 2014-06-03 00:29:43 on branch trunk — Search dialog offers (x) all channels or (x) just current for server+cache scan again. Removed search="" parameter from channels that don't implement it. (To remove extraneous .has_search channel attribute again somewhen..)

    External: Xiph IO cache ?search= should be changed to work on station titles instead of genres. (user: mario, size: 44946) [annotate] [blame] [check-ins using]


583
584
585
586
587
588
589

590
591
592
593
594
595
596
597
598
599
600
601
602




603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654

655
656
657
658
659
660
661
# and also: quick search textbox (uses main.q instead)
class search (auxiliary_window):


        # show search dialog   
        def menu_search(self, w):
            self.search_dialog.show();



        # hide dialog box again
        def cancel(self, *args):
            self.search_dialog.hide()
            return True  # stop any other gtk handlers
            

        # prepare variables
        def prepare_search(self):
            main.status("Searching... Stand back.")
            self.cancel()
            self.q = self.search_full.get_text().lower()




            main.bookmarks.streams["search"] = []
            
        # perform search
        def cache_search(self, *w):
            self.prepare_search()
            entries = []
            # which fields?
            fields = ["title", "playing", "homepage"]
            #if not self.search_in_all.get_active():
            #    fields = [f for f in fields if (main.get_widget("search_in_"+f) and main.get_widget("search_in_"+f).get_active())]
            # channels?
            channels = main.channel_names[:]
            #if not self.search_channel_all.get_active():
            #    channels = [c for c in channels if main.get_widget("search_channel_"+c).get_active()]
            for c in channels:
                if main.channels[c] and main.channels[c].streams:  # skip disabled plugins
                    # categories
                    for cat in main.channels[c].streams.keys():
                        # stations
                        for row in main.channels[c].streams[cat]:
                            # assemble text fields to compare
                            text = " ".join([row.get(f, " ") for f in fields])
                            if text.lower().find(self.q) >= 0:
                                row["genre"] = c + " " + row["genre"]
                                entries.append(row)
            self.show_results(entries)

        # display "search" in "bookmarks"
        def show_results(self, entries):
            main.status(1.0)
            main.channel_switch(None, "bookmarks", 0)
            main.bookmarks.set_category("search")
            # insert data and show
            main.channels["bookmarks"].streams["search"] = entries   # we have to set it here, else .currentcat() might reset it 
            main.bookmarks.load("search")
            
            
        # live search on directory server homepages
        def server_search(self, w):
            self.prepare_search()
            entries = []
            for i,cn in enumerate([main.channels[c] for c in main.channels]):
#                main.status(main, 1.0 * i / 15)
                if cn.has_search:
                    __print__(dbg.PROC, "has_search:", cn.module)
                    try:
                        add = cn.update_streams(cat=None, search=self.q)
                        for row in add:
                            row["genre"] = cn.title + " " + row["genre"]
                        entries += add
                    except:
                        continue

            self.show_results(entries)


        # search text edited in text entry box
        def quicksearch_set(self, w, *eat, **up):
            
            # keep query string







>













>
>
>
>








<
<
<
<
<
<
|
|

|

|



|

















|
<
|




|



>







583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615






616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643

644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
# and also: quick search textbox (uses main.q instead)
class search (auxiliary_window):


        # show search dialog   
        def menu_search(self, w):
            self.search_dialog.show();
            self.search_dialog_current.set_label("just %s" % main.current_channel)


        # hide dialog box again
        def cancel(self, *args):
            self.search_dialog.hide()
            return True  # stop any other gtk handlers
            

        # prepare variables
        def prepare_search(self):
            main.status("Searching... Stand back.")
            self.cancel()
            self.q = self.search_full.get_text().lower()
            if self.search_dialog_all.get_active():
                self.targets = main.channels.keys()
            else:
                self.targets = [main.current_channel]
            main.bookmarks.streams["search"] = []
            
        # perform search
        def cache_search(self, *w):
            self.prepare_search()
            entries = []
            # which fields?
            fields = ["title", "playing", "homepage"]






            for i,cn in enumerate([main.channels[c] for c in self.targets]):
                if cn.streams:  # skip disabled plugins
                    # categories
                    for cat in cn.streams.keys():
                        # stations
                        for row in cn.streams[cat]:
                            # assemble text fields to compare
                            text = " ".join([row.get(f, " ") for f in fields])
                            if text.lower().find(self.q) >= 0:
                                row["genre"] = c + " " + row.get("genre", "")
                                entries.append(row)
            self.show_results(entries)

        # display "search" in "bookmarks"
        def show_results(self, entries):
            main.status(1.0)
            main.channel_switch(None, "bookmarks", 0)
            main.bookmarks.set_category("search")
            # insert data and show
            main.channels["bookmarks"].streams["search"] = entries   # we have to set it here, else .currentcat() might reset it 
            main.bookmarks.load("search")
            
            
        # live search on directory server homepages
        def server_search(self, w):
            self.prepare_search()
            entries = []
            for i,cn in enumerate([main.channels[c] for c in self.targets]):

                if cn.has_search:  # "search" in cn.update_streams.func_code.co_varnames:
                    __print__(dbg.PROC, "has_search:", cn.module)
                    try:
                        add = cn.update_streams(cat=None, search=self.q)
                        for row in add:
                            row["genre"] = cn.title + " " + row.get("genre", "")
                        entries += add
                    except:
                        continue
                #main.status(main, 1.0 * i / 15)
            self.show_results(entries)


        # search text edited in text entry box
        def quicksearch_set(self, w, *eat, **up):
            
            # keep query string