Preparse playlist items that don't have enough meta
authorClément Stenac <zorglub@videolan.org>
Sun, 12 Nov 2006 18:19:49 +0000 (18:19 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 12 Nov 2006 18:19:49 +0000 (18:19 +0000)
If the item is not to be preparsed but has enough meta, mark it as preparsed

15 files changed:
include/vlc/vlc.h
include/vlc_playlist.h
modules/demux/playlist/asx.c
modules/demux/playlist/b4s.c
modules/demux/playlist/dvb.c
modules/demux/playlist/gvp.c
modules/demux/playlist/m3u.c
modules/demux/playlist/pls.c
modules/demux/playlist/podcast.c
modules/demux/playlist/qtl.c
modules/demux/playlist/sgimb.c
modules/demux/playlist/shoutcast.c
modules/demux/playlist/xspf.c
src/playlist/engine.c
src/playlist/item.c

index f85164b..400075d 100644 (file)
@@ -141,6 +141,7 @@ struct vlc_list_t
 #define PLAYLIST_APPEND          0x0002
 #define PLAYLIST_GO              0x0004
 #define PLAYLIST_PREPARSE        0x0008
+#define PLAYLIST_SPREPARSE       0x0010
 
 #define PLAYLIST_END           -666
 
index 7f45120..cc23948 100644 (file)
@@ -128,6 +128,7 @@ struct playlist_t
 
     vlc_bool_t            b_doing_ml; /**< Doing media library stuff, */
                                       /*get quicker */
+    vlc_bool_t            b_auto_preparse;
 
     /* Runtime */
     input_thread_t *      p_input;  /**< the input thread associated
index 472d225..a3d44ae 100644 (file)
@@ -370,8 +370,8 @@ static int Demux( demux_t *p_demux )
                             input_ItemCopyOptions( p_current->p_input, p_input );
                             playlist_BothAddInput( p_playlist, p_input,
                                                    p_item_in_category,
-                                                   PLAYLIST_APPEND,
-                                                   PLAYLIST_END );
+                                            PLAYLIST_APPEND|PLAYLIST_SPREPARSE,
+                                            PLAYLIST_END );
                             free( psz_string );
                         }
                         else continue;
@@ -450,7 +450,8 @@ static int Demux( demux_t *p_demux )
                             if( psz_abstract_entry ) vlc_meta_SetDescription( p_entry->p_meta, psz_abstract_entry );
                             playlist_BothAddInput( p_playlist, p_entry,
                                                  p_item_in_category,
-                                                 PLAYLIST_APPEND, PLAYLIST_END);
+                                                 PLAYLIST_APPEND | PLAYLIST_SPREPARSE
+                                                 , PLAYLIST_END);
                             free( psz_string );
                         }
                         else continue;
index 2ab29e0..baa52f9 100644 (file)
@@ -268,7 +268,8 @@ static int Demux( demux_t *p_demux )
 
                     playlist_BothAddInput( p_playlist, p_input,
                                            p_item_in_category,
-                                           PLAYLIST_APPEND, PLAYLIST_END );
+                                           PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                                           PLAYLIST_END );
                     FREENULL( psz_name );
                     FREENULL( psz_mrl );
                     FREENULL( psz_genre );
index bd3a56c..0c0eeb1 100644 (file)
@@ -119,7 +119,8 @@ static int Demux( demux_t *p_demux )
             input_ItemAddOption( p_input, ppsz_options[i] );
         }
         playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
-                               PLAYLIST_APPEND, PLAYLIST_END );
+                               PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                               PLAYLIST_END );
 
         while( i_options-- ) free( ppsz_options[i_options] );
         if( ppsz_options ) free( ppsz_options );
index b81a5ff..23ecc4d 100644 (file)
@@ -215,7 +215,8 @@ static int Demux( demux_t *p_demux )
         SADD_INFO( "description", psz_description );
         playlist_BothAddInput( p_sys->p_playlist, p_input,
                                p_sys->p_item_in_category,
-                               PLAYLIST_APPEND, PLAYLIST_END );
+                               PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                               PLAYLIST_END );
     }
 
     HANDLE_PLAY_AND_RELEASE;
index 124c4b8..25e2594 100644 (file)
@@ -169,7 +169,8 @@ static int Demux( demux_t *p_demux )
                 input_ItemAddInfo( p_input, _(VLC_META_INFO_CAT),
                                         _(VLC_META_ARTIST), "%s", psz_artist );
             playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
-                                   PLAYLIST_APPEND, PLAYLIST_END );
+                                   PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                                   PLAYLIST_END );
             free( psz_mrl );
         }
 
index 158ce4d..816cdbb 100644 (file)
@@ -157,7 +157,8 @@ static int Demux( demux_t *p_demux )
                                             0, NULL, -1 );
                 input_ItemCopyOptions( p_current->p_input, p_input );
                 playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
-                                        PLAYLIST_APPEND, PLAYLIST_END );
+                                       PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                                       PLAYLIST_END );
             }
             else
             {
@@ -213,7 +214,8 @@ static int Demux( demux_t *p_demux )
         p_input = input_ItemNewExt( p_playlist, psz_mrl, psz_name,0, NULL, -1 );
         input_ItemCopyOptions( p_current->p_input, p_input );
         playlist_BothAddInput( p_playlist, p_input, p_item_in_category,
-                               PLAYLIST_APPEND, PLAYLIST_END );
+                               PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                               PLAYLIST_END );
         free( psz_mrl_orig );
         psz_mrl = NULL;
     }
index d8a020b..78976e8 100644 (file)
@@ -293,7 +293,8 @@ static int Demux( demux_t *p_demux )
                     }
                     playlist_BothAddInput( p_playlist, p_input,
                                            p_item_in_category,
-                                           PLAYLIST_APPEND, PLAYLIST_END );
+                                           PLAYLIST_APPEND | PLAYLIST_SPREPARSE
+                                           , PLAYLIST_END );
                     FREENULL( psz_item_name );
                     FREENULL( psz_item_mrl );
                     FREENULL( psz_item_size );
index 3f499a8..cae957b 100644 (file)
@@ -361,7 +361,8 @@ static int Demux( demux_t *p_demux )
         SADD_INFO( "href", psz_href );
         SADD_INFO( "mime type", psz_mimetype );
         playlist_BothAddInput( p_sys->p_playlist, p_input,
-                               p_sys->p_item_in_category, PLAYLIST_APPEND,
+                               p_sys->p_item_in_category,
+                               PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
                                PLAYLIST_END );
         if( psz_qtnext )
         {
@@ -369,7 +370,8 @@ static int Demux( demux_t *p_demux )
                                         psz_qtnext, NULL, 0, NULL, -1 );
             playlist_BothAddInput( p_sys->p_playlist, p_input,
                                    p_sys->p_item_in_category,
-                                   PLAYLIST_APPEND, PLAYLIST_END );
+                                   PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                                   PLAYLIST_END );
         }
     }
 
index 9f00eac..cc3da44 100644 (file)
@@ -407,7 +407,7 @@ static int Demux ( demux_t *p_demux )
     }
 
     playlist_BothAddInput( p_playlist, p_child, p_item_in_category,
-                           PLAYLIST_APPEND, PLAYLIST_END );
+                           PLAYLIST_APPEND | PLAYLIST_SPREPARSE, PLAYLIST_END );
     HANDLE_PLAY_AND_RELEASE
     return -1; /* Needed for correct operation of go back */
 }
index 199f8d0..2bad421 100644 (file)
@@ -242,7 +242,8 @@ static int DemuxGenre( demux_t *p_demux )
                     free( psz_mrl );
                     playlist_BothAddInput( p_sys->p_playlist, p_input,
                                            p_sys->p_item_in_category,
-                                           PLAYLIST_APPEND, PLAYLIST_END );
+                                           PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                                           PLAYLIST_END );
                     FREENULL( psz_name );
                 }
                 FREENULL( psz_eltname );
@@ -433,7 +434,8 @@ static int DemuxStation( demux_t *p_demux )
 
                     playlist_BothAddInput( p_sys->p_playlist, p_input,
                                            p_sys->p_item_in_category,
-                                           PLAYLIST_APPEND, PLAYLIST_END );
+                                           PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                                           PLAYLIST_END );
 
                     FREENULL( psz_name );
                     FREENULL( psz_mt )
index 83f8a59..7be83eb 100644 (file)
@@ -481,7 +481,8 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE
                     FREE_ATT();
                     playlist_BothAddInput( p_playlist, p_new_input,
                                            p_demux->p_sys->p_item_in_category,
-                                           PLAYLIST_APPEND, PLAYLIST_END );
+                                           PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
+                                           PLAYLIST_END );
                     if( p_demux->p_sys->i_identifier <
                         p_demux->p_sys->i_tracklist_entries )
                     {
index 6c798e1..9840a3f 100644 (file)
@@ -53,6 +53,7 @@ static int RandomCallback( vlc_object_t *p_this, char const *psz_cmd,
 playlist_t * playlist_Create( vlc_object_t *p_parent )
 {
     playlist_t *p_playlist;
+    vlc_bool_t b_save;
     int i_tree;
 
     /* Allocate structure */
@@ -90,6 +91,9 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
 
     p_playlist->b_doing_ml = VLC_FALSE;
 
+    p_playlist->b_auto_preparse =
+                        var_CreateGetBool( p_playlist, "auto-preparse") ;
+
     p_playlist->p_root_category = playlist_NodeCreate( p_playlist, NULL, NULL);
     p_playlist->p_root_onelevel = playlist_NodeCreate( p_playlist, NULL, NULL);
 
@@ -132,8 +136,10 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
     p_playlist->i_order = ORDER_NORMAL;
 
     vlc_object_attach( p_playlist, p_parent );
-
+    b_save = p_playlist->b_auto_preparse;
+    p_playlist->b_auto_preparse = VLC_FALSE;
     playlist_MLLoad( p_playlist );
+    p_playlist->b_auto_preparse = VLC_TRUE;
     return p_playlist;
 }
 
index 0ae600b..64a9887 100644 (file)
@@ -574,11 +574,22 @@ void GoAndPreparse( playlist_t *p_playlist, int i_mode,
         p_playlist->request.i_status = PLAYLIST_RUNNING;
         vlc_cond_signal( &p_playlist->object_wait );
     }
-    if( i_mode & PLAYLIST_PREPARSE &&
-        var_CreateGetBool( p_playlist, "auto-preparse" ) )
-    {
+    /* Preparse if PREPARSE or SPREPARSE & not enough meta */
+    if( p_playlist->b_auto_preparse &&
+          (i_mode & PLAYLIST_PREPARSE ||
+          ( i_mode & PLAYLIST_SPREPARSE &&
+            ( !p_item_cat->p_input->p_meta || (p_item_cat->p_input->p_meta &&
+              ( EMPTY_STR( p_item_cat->p_input->p_meta->psz_artist ) ||
+                EMPTY_STR( p_item_cat->p_input->p_meta->psz_album ) )
+              )
+            )
+          ) ) )
         playlist_PreparseEnqueue( p_playlist, p_item_cat->p_input );
-    }
+    /* If we already have it, signal it */
+    else if( p_item_cat->p_input->p_meta &&
+             !EMPTY_STR( p_item_cat->p_input->p_meta->psz_artist ) &&
+             !EMPTY_STR( p_item_cat->p_input->p_meta->psz_album ) )
+        p_item_cat->p_input->p_meta->i_status = ITEM_PREPARSED;
 }
 
 /* Add the playlist item to the requested node and fire a notification */