]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
epggrab: add possibility to re-run internal EPG grabbers
authorJaroslav Kysela <perex@perex.cz>
Wed, 11 May 2016 07:42:12 +0000 (09:42 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 11 May 2016 07:42:12 +0000 (09:42 +0200)
src/api/api_epggrab.c
src/epggrab.c
src/epggrab.h
src/webui/static/app/epggrab.js

index fc35bfa753a60d9477a836690ff809bf440a5fef..f53f6f00e6c111de922eafc6e55fb1b8f7757fbf 100644 (file)
@@ -68,6 +68,21 @@ api_epggrab_ota_trigger
   return 0;
 }
 
+static int
+api_epggrab_rerun_internal
+  ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
+{
+  int32_t s32;
+  if (htsmsg_get_s32(args, "rerun", &s32))
+    return EINVAL;
+  if (s32 > 0) {
+    pthread_mutex_lock(&global_lock);
+    epggrab_rerun_internal();
+    pthread_mutex_unlock(&global_lock);
+  }
+  return 0;
+}
+
 void api_epggrab_init ( void )
 {
   static api_hook_t ah[] = {
@@ -79,6 +94,7 @@ void api_epggrab_init ( void )
     { "epggrab/config/load",  ACCESS_ADMIN, api_idnode_load_simple, &epggrab_conf.idnode },
     { "epggrab/config/save",  ACCESS_ADMIN, api_idnode_save_simple, &epggrab_conf.idnode },
     { "epggrab/ota/trigger",  ACCESS_ADMIN, api_epggrab_ota_trigger, NULL },
+    { "epggrab/internal/rerun",  ACCESS_ADMIN, api_epggrab_rerun_internal, NULL },
     { NULL },
   };
 
index dc7acbd6d079dde4c445f5d2942a4e17ae5006e5..0809a7e4ee6373f40eaab786f29523718865aa2d 100644 (file)
@@ -136,6 +136,13 @@ static void* _epggrab_internal_thread ( void* p )
   return NULL;
 }
 
+void
+epggrab_rerun_internal(void)
+{
+  epggrab_confver++;
+  pthread_cond_signal(&epggrab_cond);
+}
+
 /* **************************************************************************
  * Configuration
  * *************************************************************************/
@@ -193,8 +200,7 @@ static void
 epggrab_class_changed(idnode_t *self)
 {
   /* Register */
-  epggrab_confver++;
-  pthread_cond_signal(&epggrab_cond);
+  epggrab_rerun_internal();
 }
 
 static htsmsg_t *
index 20e101effa6c71e90f91cd1216f7b57a7b784f57..6b5cbd9f60f4b483ce7ae4578ad2d733bdbe5cac 100644 (file)
@@ -306,6 +306,7 @@ extern int                   epggrab_ota_running;
 int epggrab_activate_module       ( epggrab_module_t *mod, int activate );
 void epggrab_ota_set_cron         ( void );
 void epggrab_ota_trigger          ( int secs );
+void epggrab_rerun_internal       ( void );
 
 /*
  * Load/Save
index 990250f27099f79ab8586f891b1244ff8bef4073..f2eafa9761526eb129d83f7ff2101719c54bfe51 100644 (file)
@@ -1,3 +1,22 @@
+tvheadend.epggrab_rerun_button = function() {
+    return {
+        name: 'trigger',
+        builder: function() {
+            return new Ext.Toolbar.Button({
+                text: _("Re-run Internal EPG Grabbers"),
+                tooltip: _('Re-run all internal EPG grabbers to import EPG data now'),
+                iconCls: 'find',
+            });
+        },
+        callback: function(conf) {
+            tvheadend.Ajax({
+               url: 'api/epggrab/internal/rerun',
+               params: { rerun: 1 },
+            });
+        }
+    };
+}
+
 tvheadend.epggrab_base = function(panel, index) {
 
     var triggerButton = {
@@ -25,7 +44,7 @@ tvheadend.epggrab_base = function(panel, index) {
         tabIndex: index,
         width: 550,
         labelWidth: 200,
-        tbar: [triggerButton]
+        tbar: [triggerButton, tvheadend.epggrab_rerun_button()]
     });
 
 }
@@ -73,7 +92,8 @@ tvheadend.epggrab_mod = function(panel, index) {
         fields: ['uuid', 'title', 'status'],
         list: { url: 'api/epggrab/module/list', params: { } },
         lcol: [actions],
-        plugins: [actions]
+        plugins: [actions],
+        tbar: [tvheadend.epggrab_rerun_button()]
     });
 
 };