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

⌈⌋ branch:  streamtuner2


Diff

Differences From Artifact [02ec24050c]:

To Artifact [f68e153942]:


213
214
215
216
217
218
219
220
221


222
223
224
225
226
227
228
229
213
214
215
216
217
218
219


220
221

222
223
224
225
226
227
228







-
-
+
+
-






                "menu_projhomepage": lambda w: action.browser("http://milki.include-once.org/streamtuner2/"),
               # "menu_bugreport": lambda w: BugReport(),
                "menu_copy": self.menu_copy,
                "delete_entry": self.delete_entry,
                # search dialog
                "quicksearch_set": search.quicksearch_set,
                "search_open": search.menu_search,
                "search_go": search.start,
                "search_srv": search.start,
                "search_go": search.cache_search,
                "search_srv": search.server_search,
                "search_google": search.google,
                "search_cancel": search.cancel,
                "true": lambda w,*args: True,
                # win_streamedit
                "streamedit_open": streamedit.open,
                "streamedit_save": streamedit.save,
                "streamedit_new": streamedit.new,
                "streamedit_cancel": streamedit.cancel,
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
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
662







-
-
-
+
+
+
+

-
-

-


+
+
+
+

-
-
-
+
+
+


-
-
+
+
-
-


-


-


-
-
+

-
-

-
+
-

+

-
-
+
+
+








-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








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

        # prepare variables
        def prepare_search(self):
            main.status("Searching... Stand back.")
            self.cancel()
            
            # prepare variables
            self.q = self.search_full.get_text().lower()
            entries = []
            main.bookmarks.streams["search"] = []
            
        # perform search
        def cache_search(self, *w):
            self.prepare_search()
            entries = []
            # which fields?
            fields = ["title", "playing", "genre", "homepage", "url", "extra", "favicon", "format"]
            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())]
            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()]
            #if not self.search_channel_all.get_active():
            #    channels = [c for c in channels if main.get_widget("search_channel_"+c).get_active()]
            
            # step through channels
            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
                            # assemble text fields to compare
                            text = " ".join([row.get(f, " ") for f in fields])
                        
                            # compare
                            if text.lower().find(self.q) >= 0:

                                row["genre"] = c + " " + row["genre"]
                                # add result
                                entries.append(row)
            self.show_results(entries)

            
            # display "search" in "bookmarks"
        # 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_query(self, w):
            "unimplemented"

            
        # don't search at all, open a web browser
        def google(self, w):
            self.cancel()
            action.browser("http://www.google.com/search?q=" + self.search_full.get_text())
        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
            main.q = self.search_quick.get_text().lower()
955
956
957
958
959
960
961
962

963
964
965
966
967
968
969
957
958
959
960
961
962
963

964
965
966
967
968
969
970
971







-
+






        ]


        # content
        categories = ["favourite", ]  # timer, links, search, and links show up as needed
        current = "favourite"
        default = "favourite"
        streams = {"favourite":[], "search":[], "scripts":[], "timer":[], }
        streams = {"favourite":[], "search":[], "scripts":[], "timer":[], "history":[], }
        

        # cache list, to determine if a PLS url is bookmarked
        urls = []


        # this channel does not actually retrieve/parse data from anywhere