private List <PlexTableAccounts> GetPlexAccounts() { PlexDatabaseControlller plex = new PlexDatabaseControlller(GetProperty("Plex Database").Value.ToString()); if (plex.IsDbConnected) { string sql = @"SELECT id, 'Master' AS name FROM accounts WHERE id = 0 UNION ALL SELECT id, name FROM accounts WHERE id > 0;"; return(plex.ReadPlexAndMap <PlexTableAccounts>(sql)); } return(new List <PlexTableAccounts>()); }
private void SyncRatings() { if (!Settings.SyncRatings) { return; } // Get all the files to sync ratings for bwProcess.ReportProgress(0, "Reading Track Data From Plex..."); string sql = @" SELECT MTI.guid, MP.file, MTIS.rating FROM media_items MI INNER JOIN media_parts MP ON MP.media_item_id = MI.id INNER JOIN metadata_items MTI ON MTI.id = MI.metadata_item_id INNER JOIN library_sections LS ON LS.id = MI.library_section_id LEFT JOIN metadata_item_settings MTIS ON MTIS.guid = MTI.guid AND MTIS.account_id = {0} WHERE LS.section_type = 8"; sql = string.Format(sql, Settings.PlexAccountId); List <PlexRatingsData> ratingdata = m_PlexDb.ReadPlexAndMap <PlexRatingsData>(sql); bwProcess.ReportProgress(ratingdata.Count); bwProcess.ReportProgress(0, "Syncing Ratings..."); // Process all the files foreach (PlexRatingsData file in ratingdata) { if (bwProcess.CancellationPending) { return; } bwProcess.ReportProgress(0, $"Syncing \"{new FileInfo(file.file).Name}\"..."); SyncRating(file); bwProcess.ReportProgress(-1); } }