[ontv] Use system installed grabbers in assistant



commit 7455a63ad337350977f051a3abf886249bc19bc1
Author: Olof Kindgren <olki src gnome org>
Date:   Thu Oct 28 21:35:12 2010 +0200

    Use system installed grabbers in assistant
    
    If tv_find_grabbers is installed, we use that to find all grabbers
    that are installed.

 ontv/assistant.py |   48 ++++++++++++++++++------------------------------
 ontv/dialogs.py   |    1 -
 2 files changed, 18 insertions(+), 31 deletions(-)
---
diff --git a/ontv/assistant.py b/ontv/assistant.py
index 47507df..33fcab6 100644
--- a/ontv/assistant.py
+++ b/ontv/assistant.py
@@ -25,6 +25,8 @@ from gettext import gettext as _
 
 import gtk
 import gobject
+import subprocess
+
 try:
     import vte
 except ImportError, ie:
@@ -37,31 +39,6 @@ except ImportError, ie:
 import gui
 import utils
 
-GRABBERS = {"Belgium": "tv_grab_be",
-            "Brazil": "tv_grab_br",
-            "Brazil (NET cable service)": "tv_grab_br_net",
-            "Germany": "tv_grab_de_tvtoday",
-            "Denmark": "tv_grab_dk",
-            "Estonia": "tv_grab_ee",
-            "Spain": "tv_grab_es",
-            "Spain (laguiatv)": "tv_grab_es_laguiatv",
-            "Finland": "tv_grab_fi",
-            "France": "tv_grab_fr",
-            "Hungary": "tv_grab_huro",
-            "Romania": "tv_grab_huro",
-            "Iceland": "tv_grab_is",
-            "Italy": "tv_grab_it",
-            "Japan": "tv_grab_jp",
-            "North America": "tv_grab_na_dd",
-            "Netherlands": "tv_grab_nl",
-            "Netherlands (wolf)": "tv_grab_nl_wolf",
-            "Norway": "tv_grab_no",
-            "Reunion Island (France)": "tv_grab_re",
-            "Sweden": "tv_grab_se_swedb",
-            "United Kingdom (bleb.org)": "tv_grab_uk_bleb",
-            "United Kingdom (rt)": "tv_grab_uk_rt",
-            "South Africa": "tv_grab_za"}
-
 class XMLTVAssistant(gtk.Assistant):
 
     __gsignals__ = {"apply": "override", "cancel": "override",
@@ -127,10 +104,21 @@ class XMLTVAssistant(gtk.Assistant):
         self.country_combobox.connect("changed",
                                       self.__country_combobox_changed, page)
         # Add grabbers which are in path
-        for country in GRABBERS.keys():
-            grabber = GRABBERS[country]
-            if utils.is_in_path(grabber):
-                self.country_combobox.append_text(country)
+
+        cmd = "tv_find_grabbers"
+
+        self.grabbers = {}
+
+        if utils.is_in_path(cmd):
+            output = subprocess.Popen([cmd], stdout=subprocess.PIPE).communicate()[0]
+
+            for line in output.split('\n'):
+                parts = line.split('|')
+                if(len(parts)==2):
+                    self.grabbers[parts[1]] = parts[0].split('/')[-1]
+
+        for country in self.grabbers.keys():
+            self.country_combobox.append_text(country)
         installed_table.attach(self.country_combobox, 1, 2, 0, 1,
                                xoptions=gtk.EXPAND|gtk.FILL)
 
@@ -213,7 +201,7 @@ class XMLTVAssistant(gtk.Assistant):
         if country_combobox_active == -1:
             return ""
         selected_country = country_combobox_model[country_combobox_active][0]
-        grabber = GRABBERS[selected_country]
+        grabber = self.grabbers[selected_country]
         return grabber
 
     def __custom_fields_changed(self, widget, page):
diff --git a/ontv/dialogs.py b/ontv/dialogs.py
index 20c2bf2..5173ea5 100644
--- a/ontv/dialogs.py
+++ b/ontv/dialogs.py
@@ -30,7 +30,6 @@ import config
 import gui
 import utils
 from reminders import Reminder
-from assistant import GRABBERS, XMLTVAssistant
 from ontv import NAME, VERSION, LOCALE_DIR
 
 import locale



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]