My biggest irritation are the podcast entries - I have dozens of mainly BBC podcasts that I have deleted from my PC but still show up in the MM Podcast Subscriptions node. Now we can amend the tables I've put together a few SQL queries that work with the Viewer script. (And it should be possible also now to also make these actions work in vbs...)
I have 8 queries so far. They query the PodcastEpisodes and Songs tables - PodcastEpisodes is the one that populates the Podcast Subscriptions node in MM3. Just paste the code into the Viewer window and press 'Run Select Query' for the SELECT queries or 'Execute DDL/DML Statement' for the others.
Here goes:
I strongly recommend you make a backup of your MM.db file before attempting changes!
1. All podcasts in PodcastEpisodes table
Code: Select all
SELECT * FROM PodcastEpisodes ORDER BY IDTrack
Code: Select all
SELECT * FROM PodcastEpisodes WHERE IDTrack IN (SELECT PodcastEpisodes.IDTrack AS 'tmp' FROM PodcastEpisodes LEFT JOIN Songs ON PodcastEpisodes.IDTrack = Songs.ID WHERE Songs.ID Is Null)
Code: Select all
DELETE FROM PodcastEpisodes WHERE IDTrack IN (SELECT PodcastEpisodes.IDTrack AS 'tmp' FROM PodcastEpisodes LEFT JOIN Songs ON PodcastEpisodes.IDTrack = Songs.ID WHERE Songs.ID Is Null)
- This will remove ALL entries where the Songs entry is missing.
- If you have the file but it has become 'orphaned' see queries 7 & 8
- If a podcast is still active on the server it will be added back to the PodcastEpisodes table on the next update.
- If you want to prevent an active podcast from downloading change the Downloaded flag to 1 (IDTrack can be any value). See query 6.
4. Podcasts in PodcastEpisodes table awaiting download (i.e. will be picked up at next update)
Code: Select all
SELECT * FROM PodcastEpisodes WHERE IDTrack = -1 AND Downloaded = 0
- If you want to prevent the podcast from downloading change the Downloaded flag to 1 (IDTrack can be any value).
- If the podcast is not active you can delete it using the next query:
5. Delete single podcast from table (e.g. after manually removing the file)
Code: Select all
DELETE FROM PodcastEpisodes WHERE ID = nnn
- If the podcast is still active on the podcast server it will be added back to the PodcastEpisodes table on the next update.
nnn = PodcastEpisodes.ID (NOT Songs.ID)
6. Change Downloaded flag
Code: Select all
UPDATE PodcastEpisodes SET Downloaded = 0 WHERE ID = nnn
- Downloaded = 0 will attempt to save the podcast at next update (if still active)
- Downloaded = 1 will ignore updates
nnn = PodcastEpisodes.ID (NOT Songs.ID)
7. Add orphaned (existing) podcast files to PodcastEpisodes table
Code: Select all
REPLACE INTO PodcastEpisodes
( ID, IDPodcast, IDTrack, Downloaded, title, autor, link, description, subtitle, summary, PubDate, NetSource, keywords, category )
SELECT
PodcastEpisodes.ID, PodcastEpisodes.IDPodcast, Songs.ID, 1, PodcastEpisodes.title, PodcastEpisodes.autor, PodcastEpisodes.link, PodcastEpisodes.description, PodcastEpisodes.subtitle, PodcastEpisodes.summary, PodcastEpisodes.PubDate, PodcastEpisodes.NetSource, PodcastEpisodes.IDTrack, PodcastEpisodes.category
FROM PodcastEpisodes INNER JOIN Songs ON (Songs.Artist = PodcastEpisodes.autor AND Songs.Songtitle = PodcastEpisodes.Title)
WHERE
PodcastEpisodes.IDTrack <> Songs.ID
- It is recommended to run this AFTER performing an Add/Rescan Tracks routine
- This query looks for matches in the Artist & Title fields of the podcast subscriptions and song library then updates the IDTrack number to the Songs ID number
- 'autor' is how the PodcastEpisodes field appears in the database!
- Downloaded flag is set to 1
- If it takes too long to scan your Songs table try changing the WHERE clause to
Code: Select all
WHERE
PodcastEpisodes.IDTrack <> Songs.ID AND Songs.Genre = 'Podcast'8. Show all Downloaded podcasts with Podcast ID where available
Code: Select all
SELECT PodcastEpisodes.ID AS 'Podcast ID', PodcastEpisodes.IDTrack AS 'Podcast IDTrack', Songs.ID AS 'Song ID', Songs.IDAlbum, Songs.Artist, Songs.Album, Songs.SongTitle, Songs.SongPath, Songs.Year FROM Songs LEFT JOIN PodcastEpisodes ON Songs.ID = PodcastEpisodes.IDTrack WHERE Songs.Genre = 'Podcast'
[Edit 25/1/08: Modified code for last 2 queries]