[CE Project] Local Movie Catalog using JAVA and IMDB/Rottentomatoes

This is a project that has been started on CE - Labs #-Link-Snipped-#. I am posting here so new members can see it and can take part in it.

Everything that is posted here will be ralevant. CE - Labs link will be updated by proper complete code, anyone can do that.




*******The Project:***********

Problem:

Too many movies on our hard drives without proper information to sort them according to rating, release dates, themes, etc.

Solution:

To do so we need a software that will fetch all the important data from IMDB or Rottentomatoes.com.

The database will update itself using the name of the movie and fill in important columns like IMDB rating, Starring, Directed by, Written by and Category (Horror, Drama, etc).

After the database has been populated we can sort them according to any field (Rating, Directed by, Release date, etc) and have a search function.

*************************

This would now be written in Java instead of Python as planned before.

The first version will be a very basic bare-bones database.

Pour in your suggestions.

RESOURCES:

Rotten Tomatoes API for JAVA:
#-Link-Snipped-#

IMDB webservice (limited):
#-Link-Snipped-#
Java Movie Database:
www.jmdb.de

Notes:

There is a software that already does this. Called XBMC : #-Link-Snipped-#

It has a few flaws: The catalog is proper however, to play the movie we have use their movie player which does not give us the freedom to use our own player.

Secondly, it is a bloated program with music cataloging and picture cataloging too. about 35 MB.

Replies

  • xheavenlyx
    xheavenlyx
    Excellent analysis sookie. I will make it clearer or expand on it.

    Step #1:

    'x' is location of files ( directory or file(s) ) manually entered by the user where movies are kept. The software will not look for files or directory on it's own.

    Step #2:

    Look for files within the directory

    Step #3:

    If directory goto #2, if file goto #4.

    Step #4:

    Is the file a .avi, .mov, .mpeg, .mpg, .mkv etc?
    Store the name and location of the movie in a temporary database (see Step #5).

    Step #6:

    Goto IMDB/Rottontomatoes and get details for each Actual_Movie_Name:

    Movie Name (done)
    Release date
    IMDB Movie Poster or RT Poster .jpg
    IMDB Rating
    RT Rating
    Plot Summery (60 chars I think)
    Directed by
    Written by
    Starring (First billed actors only, 4 or maybe 5 names)
    Theme group (Horror, Romance, Drama, etc)
    IMDB Link
    RT Link

    Step #7:

    Store in database. Which of course can be sorted by any of the above fields. So if one night I want to watch a 60's Horror movie from my collection, I just refer to my dB and sort it and find the folder it is in.


    Step #5:

    This is an important step. Since it is very difficult to extract exact movie name from the file name through a the software.

    For example I have some movies with the format "Watchmen (2009) DVDRip-Personal" and another "bla.xfm" .

    So an intermediate database will be created first.

    File_Name, Location_PC, Actual_Movie_Name, Select

    After the database has been populated with file names. The user can select which fields he wants to Edit or remove from the list. For example it will detect all the episodes of a series as individual file names:

    File_Name          Location_PC          Actual_Movie_Name          Select
    
    bla.xfm.avi          C:\Movies\Schoolastic\
    Watchmen (2009) DVDRip-Personal.avi          C:\Movies\Watchmen
    House s01e01.avi          C:\Movies\House s01\
    House s01e03.avi          C:\Movies\House s01\
    House s01e04.avi          C:\Movies\House s01\
    House s01e05.avi          C:\Movies\House s01\
    House s01e06.avi          C:\Movies\House s01\
    House s01e07.avi          C:\Movies\House s01\
    House s01e08.avi          C:\Movies\House s01\
    

    WILL BE EDITED BY THE USER INTO:

    File_Name          Location_PC          Actual_Movie_Name          Select
    
    bla.xfm.avi          C:\Movies\Schoolastic\          Schoolastic         1
    Watchmen (2009) DVDRip-Personal.avi          C:\Movies\Watchmen          Watchmen          1
    House s01e01.avi          C:\Movies\House s01\          House M.D.          1    
    
    


    NOTE: Another small problem that can crop up is movies with the same name. Even then there would be a need for user interaction. But we will deal with that at the right time.
  • xheavenlyx
    xheavenlyx
    I am reusing a class to read files and folders from a given location.

    In the next section they will be edited to list Folders and only Movie Files.

    FileListing.java

    import java.util.*;
    import java.io.*;
    
    /**
    * Recursive file listing under a specified directory.
    *  
    * @author javapractices.com
    * @author Alex Wong
    * @author Anon
    */
    public final class FileListing {
    
      /**
      * Recursively walk a directory tree and return a List of all
      * Files found; the List is sorted using File.compareTo().
      *
      * @param aStartingDir is a valid directory, which can be read.
      */
      
       static public List getSpecListing(
        File aStartingDir
      ) throws FileNotFoundException {
        validateDirectory(aStartingDir);
        List result = getFileListingNoSort(aStartingDir);
        //Collections.sort(result);
        return result;
      }
    
      // PRIVATE //
      static public List getFileListingNoSort(
        File aStartingDir
      ) throws FileNotFoundException {
        List result = new ArrayList();	
        File[] filesAndDirs = aStartingDir.listFiles();
        List filesDirs = Arrays.asList(filesAndDirs);
        for(File file : filesDirs) {
          result.add(file); //always add, even if directory
          if ( ! file.isFile() ) {
            //must be a directory
            //recursive call! and Store Dir in new list, append to results
            List deeperList = getFileListingNoSort(file);
            result.addAll(deeperList);
          }
        }
        return result;
      }
    
      /**
      * Directory is valid if it exists, does not represent a file, and can be read.
      */
    
      static private void validateDirectory (
        File aDirectory
      ) throws FileNotFoundException {
        if (aDirectory == null) {
          throw new IllegalArgumentException("Directory should not be null.");
        }
        if (!aDirectory.exists()) {
          throw new FileNotFoundException("Directory does not exist: " + aDirectory);
        }
        if (!aDirectory.isDirectory()) {
          throw new IllegalArgumentException("Is not a directory: " + aDirectory);
        }
        if (!aDirectory.canRead()) {
          throw new IllegalArgumentException("Directory cannot be read: " + aDirectory);
        }
      }
    } 
    
    The usage of this class is in ExtractMovieName.java

    
    import com.moviedb.FileListing;
    import java.lang.String;
    import java.util.*;
    import java.io.*;
    
    public class ExtractMovieName {
    
    	/**
    	 * This Class is used to get movie names from folders and store them in a "database". 
    	 * @param args; not used
    	 * @throws FileNotFoundException 
    	 */
    
    	public static void main(String[] args) throws FileNotFoundException {
    		File filedir = new File("D:\\Movies\\");
    		
                    List files = FileListing.getSpecListing(filedir);
    		for(File file : files ){
    		      System.out.println(file);
    		    }
    	    }
    }
    
  • xheavenlyx
    xheavenlyx
    These are two methods to split the files according to their names.

    1. I am still unsure about the end result of this but I am absolutely sure about the regular expression format to find all the movie files from each String filename.

    public String[] splitMovieName (String filename) {
    	// Create a pattern to match breaks
    	Pattern p = Pattern.compile("[^\\]+\.(avi|mkv|mpg|mpeg|mp4|mov|vob|flv|mp4)$");
    	
    	// Split input with the pattern
    	String[] result = p.split(filename);
            // return result;  OR print  
    		for (int i=0; i
    2. Not using regex but split at "/" and store in array. Access from last to get movie name. Simple and effective but then we need to compare for movie suffixes before we do the split. I'll update it soon.


    public splitMovieName2 (String filename) {
    	// Create a pattern to match breaks
    	Pattern p=Pattern.compile("\\\\|\\/");
    	
    	// Split input with the pattern
    	String[] ar=pt.split(filename);
    	System.out.println(ar[ar.length-1]);
    
  • xheavenlyx
    xheavenlyx
    [PHASE 1] Get user movie list and store as dsv text file

    This is the first part of the LocalMovieDB project. Please try it out and let me know what you think. This will be expanded on for the full project and will support other OS's too in the future.

    If you like to see some feature, let me know after you test this. Imagine, your own movie database locally so you can sort your collection better! And play it back using your choice of video player.

    #-Link-Snipped-#

    PHASE 1

    Get movie list and store as delimiter separated value file.
    This version of JAR file supports windows pathnames only.

    REQUIREMENTS

    Java Run Time Environment (Usually available by default on all systems)

    USAGE

    1. Save file anywhere on disc.
    2. From your command prompt, goto file location:
    3. java -jar ExportMovieName.jar
    4. Type in your movie's directory path. Example: C:\Users\\Videos

    5. Type in location to store dsv file. Example: C\Users\\Videos

    6. If you press enter on both the prompts, it will work by default on:
    Movie Directory : C\Users\Public\Videos
    DSV File : C\Users\Public\Videos

    After you have obtained the .txt list, export it to excel to have a look or just open it with notepad.

You are reading an archived discussion.

Related Posts

This video lecture series on Environmental Air Pollution by Prof. Mukesh Sharma Department of Civil Engineering IIT Kanpur. [video=youtube;4AuwG2G_ERU]https://www.youtube.com/watch?v=4AuwG2G_ERU[/video]
Five things you should not tell your boss​ Full disclosure and transparency are undoubtedly necessary for career success. But in the modern complex corporate scenario, it doesn't mean that your...
Hello CEANs read this E-paper - Combining Electronics And Paper - CrazyEngineers
Hello ceans read this. Chemical Detectors Using Nano Sensors - CrazyEngineers
People in Samoa are going to travel in time! 😁 Cannot believe, then see this 😀 Citizens Of Samoa To Travel One Day Ahead In Time - CrazyEngineers