ConvertRhythmboxPlaylistToSandisk.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package convert_rhythmbox_player_to_sandisk;
  2. // To choose the desired Rhythmbox playlist file
  3. import java.util.Scanner;
  4. // To store the song filenames
  5. import java.util.ArrayList;
  6. // To create the ArrayList of songs from the Rhythmbox playlist
  7. import java.io.File;
  8. public class ConvertRhythmboxPlaylistToSandisk {
  9. public static void main(String[] args) {
  10. // To choose the Rhythmbox playlist for conversion
  11. Scanner keyboardInput = new Scanner(System.in);
  12. System.out.print("Which Rhythmbox playlist file did you want to convert? ");
  13. RhythmboxPlaylist rhythmboxPlaylist = new RhythmboxPlaylist(
  14. keyboardInput.next()
  15. );
  16. // Get the playlist name from the Rhythmbox playlist filename
  17. String rhythmboxPlaylistName = rhythmboxPlaylist.getName();
  18. // Create the SanDisk playlist
  19. System.out.println("Creating the SanDisk playlist file...");
  20. SandiskPlaylist sandiskPlaylist = new SandiskPlaylist(
  21. rhythmboxPlaylistName + "_sandisk.m3u"
  22. );
  23. // Get all the songs from the playlist
  24. System.out.println("Getting all the songs from the Rhythmbox playlist...");
  25. ArrayList<File> songs = rhythmboxPlaylist.getPlaylistSongs();
  26. // Create the SanDisk playlist
  27. System.out.println("Adding all the songs to the SanDisk playlist...");
  28. sandiskPlaylist.createPlaylistFromSongs(songs);
  29. /* Delete songs that aren't in the playlist from the folder,
  30. and add songs that are in the playlist, but not currently in the folder,
  31. to the folder */
  32. SandiskPlaylistFolder folder = new SandiskPlaylistFolder(
  33. rhythmboxPlaylistName, rhythmboxPlaylist
  34. );
  35. System.out.println("Deleting songs not in Rhythmbox playlist...");
  36. folder.deleteExtraSongsFromFolder();
  37. System.out.println("Copying Rhythmbox playlist songs to SanDisk folder...");
  38. folder.copyMissingSongsToFolder();
  39. System.out.println("Done.");
  40. }
  41. }