def initialize_scheduler():
 from headphones import updater, searcher, librarysync, postprocessor, torrentfinished
 with SCHED_LOCK:
  start_jobs = (not len(SCHED.get_jobs()))
  minutes = CONFIG.SEARCH_INTERVAL
  schedule_job(searcher.searchforalbum, 'Search for Wanted', hours=0, minutes=minutes)
  minutes = CONFIG.DOWNLOAD_SCAN_INTERVAL
  schedule_job(postprocessor.checkFolder, 'Download Scan', hours=0, minutes=minutes)
  hours = CONFIG.LIBRARYSCAN_INTERVAL
  schedule_job(librarysync.libraryScan, 'Library Scan', hours=hours, minutes=0)
  hours = CONFIG.UPDATE_DB_INTERVAL
  schedule_job(updater.dbUpdate, 'MusicBrainz Update', hours=hours, minutes=0)
  if CONFIG.CHECK_GITHUB:
   if CONFIG.CHECK_GITHUB_INTERVAL:
    minutes = CONFIG.CHECK_GITHUB_INTERVAL
   else:
    minutes = 0
   schedule_job(versioncheck.checkGithub, 'Check GitHub for updates', hours=0, minutes=minutes)
  minutes = CONFIG.TORRENT_REMOVAL_INTERVAL
  schedule_job(torrentfinished.checkTorrentFinished, 'Torrent removal check', hours=0, minutes=minutes)
  if (start_jobs and len(SCHED.get_jobs())):
   try:
    SCHED.start()
   except Exception as e:
    logger.info(e)

def initialize_scheduler ( ) : from headphones import updater , searcher , librarysync , postprocessor , torrentfinished with SCHED_LOCK : start_jobs = ( not len ( SCHED . get_jobs ( ) ) ) minutes = CONFIG . SEARCH_INTERVAL schedule_job ( searcher . searchforalbum , 'Search for Wanted' , hours = 0 , minutes = minutes ) minutes = CONFIG . DOWNLOAD_SCAN_INTERVAL schedule_job ( postprocessor . checkFolder , 'Download Scan' , hours = 0 , minutes = minutes ) hours = CONFIG . LIBRARYSCAN_INTERVAL schedule_job ( librarysync . libraryScan , 'Library Scan' , hours = hours , minutes = 0 ) hours = CONFIG . UPDATE_DB_INTERVAL schedule_job ( updater . dbUpdate , 'MusicBrainz Update' , hours = hours , minutes = 0 ) if CONFIG . CHECK_GITHUB : if CONFIG . CHECK_GITHUB_INTERVAL : minutes = CONFIG . CHECK_GITHUB_INTERVAL else : minutes = 0 schedule_job ( versioncheck . checkGithub , 'Check GitHub for updates' , hours = 0 , minutes = minutes ) minutes = CONFIG . TORRENT_REMOVAL_INTERVAL schedule_job ( torrentfinished . checkTorrentFinished , 'Torrent removal check' , hours = 0 , minutes = minutes ) if ( start_jobs and len ( SCHED . get_jobs ( ) ) ) : try : SCHED . start ( ) except Exception as e : logger . info ( e )
start the scheduled background tasks .