Exemple #1
0
 private static String getTrailer(Movie movie) {
   String trailerLink = "";
   if (Integer.valueOf(movie.getMovieYear()) < 1990) {
     trailerLink = "null";
   } else {
     trailerLink += "http://www.youtube.com";
     String link = formatYoutubeString(movie.getMovieName());
     try {
       Document d = Jsoup.connect("http://www.youtube.com/" + link).get();
       Element e = d.body();
       String html = e.toString();
       String linkDiv = "";
       int max = html.indexOf("class=\"yt-lockup-title \"><a href=\"") + 100;
       for (int i = html.indexOf("class=\"yt-lockup-title \"><a href=\""); i < max; i++) {
         linkDiv += html.charAt(i);
       }
       for (int i = linkDiv.indexOf("<a href=\"") + 9;
           i < linkDiv.indexOf("class=\"yt-uix-sessionlink") - 2;
           i++) {
         trailerLink += linkDiv.charAt(i);
       }
     } catch (Exception e) {
       System.out.println(e.toString());
     }
   }
   return trailerLink;
 }
Exemple #2
0
 private static void getSQL(ArrayList<Movie> movies) {
   for (Movie m : movies) {
     System.out.println(
         "\nINSERT INTO \"ADMIN\".\"movie\" (\"title\", \"poster_link\", \"trailer_link\", \"rating\", \"actors\", \"genre\", \"description\", \"release_year\")\n"
             + "    VALUES ('"
             + m.getMovieName()
             + "',\n '"
             + m.getPosterLink()
             + "',\n '"
             + m.getTrailerLink()
             + "',\n "
             + m.getRating()
             + ",\n '"
             + m.getActors()
             + "',\n "
             + "(SELECT \"genre\".\"id\" FROM \"genre\" WHERE \"genre\".\"title\"='"
             + m.getGenre()
             + "'),\n '"
             + m.getMovieDescription()
             + "',\n '"
             + m.getMovieYear()
             + "');");
   }
 }