Assembla home | Assembla project page
 

Changeset 1012

Show
Ignore:
Timestamp:
07/04/08 01:02:26 (5 months ago)
Author:
Pernod
Message:

Improved media search to only scan what is requested. ie. If only a TV category is scanned then TV details will be parsed too, but not movies. A RSS update will now only update RSS feeds and nothing else.
Also added some more media scan status messages since users noted that a scan can sit at 100% complete for awhile when it's actually parsing TV/movie details and removing orphaned data from the database.

Fixes #146

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/swisscenter/base/media.php

    r1008 r1012  
    161161  @db_sqlcommand('DELETE FROM tv     USING tv, tv_del         WHERE tv.file_id = tv_del.file_id'); 
    162162  @db_sqlcommand('DELETE FROM photos USING photos, photos_del WHERE photos.file_id = photos_del.file_id');   
     163} 
     164 
     165/** 
     166 * Remove all MEDIA_SCAN settings from SYSTEM_PREFS. 
     167 * 
     168 */ 
     169 
     170function clear_media_scan_prefs() 
     171{ 
     172  db_sqlcommand("delete from system_prefs where name like 'media_scan_%'");  
    163173} 
    164174 
  • trunk/swisscenter/base/rss.php

    r963 r1012  
    9393     } 
    9494   } 
     95   send_to_log(4,'Finished updating RSS subscriptions'); 
    9596 } 
    9697  
  • trunk/swisscenter/config/config_media.php

    r1001 r1012  
    7676  function media_search() 
    7777  { 
    78     // Store the parameters to the media search (catgory, media tyoe) in the system_prefs table 
     78    // Store the parameters to the media search (category, media type) in the system_prefs table 
    7979    // as this is the only way of passing the info to the background process in Simese. 
     80    clear_media_scan_prefs(); 
    8081    set_sys_pref('MEDIA_SCAN_TYPE',$_REQUEST["scan_type"]); 
    8182    set_sys_pref('MEDIA_SCAN_MEDIA_TYPE',$_REQUEST["type"]); 
    8283    set_sys_pref('MEDIA_SCAN_CATEGORY',$_REQUEST["cat"]); 
    83     set_sys_pref('REFRESH_METADATA',$_REQUEST["refresh"]); 
     84    set_sys_pref('MEDIA_SCAN_REFRESH_METADATA',$_REQUEST["refresh"]); 
    8485    set_sys_pref('MEDIA_SCAN_ITUNES',$_REQUEST["itunes"]); 
    8586    set_sys_pref('MEDIA_SCAN_RSS',$_REQUEST["rss_id"]); 
     
    114115                                              where ml.cat_id = c.cat_id order by c.cat_name", $_REQUEST['cat'],true,false,str('ALL_CATEGORIES')); 
    115116    echo '<tr><td></td><td>&nbsp;</td></tr>'; 
    116     form_radio_static('refresh',str('REFRESH_METADATA'),$option_vals,get_sys_pref('REFRESH_METADATA','NO'),false,true); 
     117    form_radio_static('refresh',str('REFRESH_METADATA'),$option_vals,get_sys_pref('MEDIA_SCAN_REFRESH_METADATA','NO'),false,true); 
    117118    form_label(str('REFRESH_METADATA_PROMPT')); 
    118119    form_radio_static('itunes',str('REFRESH_ITUNES'),$option_vals,get_sys_pref('MEDIA_SCAN_ITUNES','NO'),false,true); 
  • trunk/swisscenter/do_refresh.php

    r974 r1012  
    4949  function do_refresh_all() 
    5050  { 
     51    set_sys_pref('MEDIA_SCAN_TYPE','MEDIA'); 
    5152    set_sys_pref('MEDIA_SCAN_STATUS',str('MEDIA_SCAN_STATUS_PENDING')); 
    5253    media_refresh_now(); 
     
    6263  function do_refresh_cat( $spec ) 
    6364  { 
    64     set_sys_pref('MEDIA_SCAN_MEDIA_TYPE',''); 
    6565    set_sys_pref('MEDIA_SCAN_CATEGORY',$spec); 
    6666    do_refresh_all(); 
     
    7676  { 
    7777    set_sys_pref('MEDIA_SCAN_MEDIA_TYPE',$spec); 
    78     set_sys_pref('MEDIA_SCAN_CATEGORY',''); 
    7978    do_refresh_all(); 
    8079  } 
     
    145144    show_progress(); 
    146145  elseif ( $type == 'all' ) 
     146  { 
     147    clear_media_scan_prefs(); 
    147148    do_refresh_all(); 
     149  } 
    148150  elseif ( $type == 'media_type' && empty($spec) ) 
    149151    choose_type(); 
    150152  elseif ( $type == 'media_type' ) 
     153  { 
     154    clear_media_scan_prefs(); 
    151155    do_refresh_type($spec); 
     156  } 
    152157  elseif ( $type == 'category' && empty($spec) ) 
    153158    choose_category(); 
    154159  elseif ( $type == 'category' ) 
     160  { 
     161    clear_media_scan_prefs(); 
    155162    do_refresh_cat($spec); 
     163  } 
    156164  else 
    157165    choose_main_opt();   
  • trunk/swisscenter/lang/en/en.xml

    r1009 r1012  
    18241824      </string> 
    18251825      <string> 
     1826        <id>MEDIA_SCAN_STATUS_CLEANUP</id> 
     1827        <text>Cleaning database</text> 
     1828        <version>1.20.1</version> 
     1829      </string> 
     1830      <string> 
    18261831        <id>MEDIA_SCAN_STATUS_COMPLETE</id> 
    18271832        <text>Complete</text> 
     
    18291834      </string> 
    18301835      <string> 
     1836        <id>MEDIA_SCAN_STATUS_ITUNES</id> 
     1837        <text>Parsing iTunes library</text> 
     1838        <version>1.20.1</version> 
     1839      </string> 
     1840      <string> 
     1841        <id>MEDIA_SCAN_STATUS_MOVIE</id> 
     1842        <text>Parsing movie details</text> 
     1843        <version>1.20.1</version> 
     1844      </string> 
     1845      <string> 
    18311846        <id>MEDIA_SCAN_STATUS_PENDING</id> 
    18321847        <text>Pending</text> 
     
    18371852        <text>Running</text> 
    18381853        <version>1.19</version> 
     1854      </string> 
     1855      <string> 
     1856        <id>MEDIA_SCAN_STATUS_TV</id> 
     1857        <text>Parsing TV details</text> 
     1858        <version>1.20.1</version> 
    18391859      </string> 
    18401860      <string> 
  • trunk/swisscenter/media_search.php

    r959 r1012  
    4646      if ($media_type == MEDIA_TYPE_MUSIC) 
    4747        musicip_server_add_dir($location["NAME"]);     
    48  
     48   
    4949 
    5050  } 
     
    6262  $cat_id     = get_sys_pref('MEDIA_SCAN_CATEGORY'); 
    6363  $itunes     = get_sys_pref('MEDIA_SCAN_ITUNES','YES'); 
    64   $update     = get_sys_pref('REFRESH_METADATA','NO'); 
     64  $update     = get_sys_pref('MEDIA_SCAN_REFRESH_METADATA','NO'); 
    6565  $itunes_library = get_sys_pref('ITUNES_LIBRARY'); 
    6666  $itunes_date    = get_sys_pref('ITUNES_LIBRARY_DATE'); 
     67  $media_types    = db_col_to_list("select distinct(media_type) from media_locations where 1=1". 
     68                                  (empty($cat_id) ? '' : " and cat_id = $cat_id"). 
     69                              (empty($media_type) ? '' : " and media_type = $media_type")); 
    6770 
    68   delete_sys_pref('MEDIA_SCAN_TYPE'); 
    69   delete_sys_pref('MEDIA_SCAN_RSS'); 
    70   delete_sys_pref('MEDIA_SCAN_MEDIA_TYPE'); 
    71   delete_sys_pref('MEDIA_SCAN_CATEGORY'); 
    72   delete_sys_pref('MEDIA_SCAN_ITUNES'); 
    73   delete_sys_pref('REFRESH_METADATA'); 
     71  db_sqlcommand("delete from system_prefs where name like 'media_scan_%'");  
    7472  set_sys_pref('MEDIA_SCAN_STATUS',str('MEDIA_SCAN_STATUS_RUNNING')); 
    7573   
     
    8785     
    8886    // Update video details from the Internet if enabled 
    89     if ( is_movie_check_enabled() ) 
     87    if ( is_movie_check_enabled() && in_array(MEDIA_TYPE_VIDEO, $media_types) ) 
     88    { 
     89      set_sys_pref('MEDIA_SCAN_STATUS',str('MEDIA_SCAN_STATUS_MOVIE')); 
    9090      extra_get_all_movie_details(); 
     91    } 
    9192     
    92     if ( is_tv_check_enabled() ) 
     93    if ( is_tv_check_enabled() && in_array(MEDIA_TYPE_TV, $media_types) ) 
     94    { 
     95      set_sys_pref('MEDIA_SCAN_STATUS',str('MEDIA_SCAN_STATUS_TV')); 
    9396      extra_get_all_tv_details(); 
     97    } 
    9498  
    9599    // Scan the iTunes library for playlists 
     
    100104      if ( is_null($itunes_date) || ($itunes_date < $file_date) ) 
    101105      { 
     106        set_sys_pref('MEDIA_SCAN_STATUS',str('MEDIA_SCAN_STATUS_ITUNES')); 
    102107        parse_itunes_file($itunes_library); 
    103108        set_sys_pref('ITUNES_LIBRARY_DATE', $file_date); 
     
    106111        send_to_log(4,'Skipping the iTunes Music Library, not changed since last update'); 
    107112    } 
     113     
     114    // Remove media from library no longer in media locations 
     115    set_sys_pref('MEDIA_SCAN_STATUS',str('MEDIA_SCAN_STATUS_CLEANUP')); 
     116    remove_orphaned_records(); 
     117    remove_orphaned_movie_info(); 
     118    remove_orphaned_tv_info(); 
     119    scdb_remove_orphans(); 
     120    eliminate_duplicates(); 
    108121  } 
    109122     
     
    123136  } 
    124137   
    125   remove_orphaned_records(); 
    126   remove_orphaned_movie_info(); 
    127   remove_orphaned_tv_info(); 
    128   scdb_remove_orphans(); 
    129   eliminate_duplicates(); 
    130138  media_indicator('OFF'); 
    131139 
  • trunk/swisscenter/rss_feeds.php

    r987 r1012  
    6464    // Store the parameters to the media search (rss subscription id) in the system_prefs table 
    6565    // as this is the only way of passing the info to the background process in Simese. 
     66    clear_media_scan_prefs(); 
    6667    set_sys_pref('MEDIA_SCAN_TYPE','RSS'); 
    6768    set_sys_pref('MEDIA_SCAN_RSS',$_REQUEST["update_id"]);