package controllers;

import dataload.ImdbDataLoad;
import dataload.TvdbDataLoad;
import play.Logger;
import play.mvc.Controller;
import play.mvc.Http;
import play.mvc.Result;
import views.html.index;

public class Application extends Controller {

    public static Result index() {

        return ok(index.render());

    }

    public static Result setUp(boolean fromFilesOnly) {

        if (!Http.Context.current().request().remoteAddress().equals("127.0.0.1")) {
            return forbidden();
        }


        ImdbDataLoad imdbDataLoad = new ImdbDataLoad();
        TvdbDataLoad tvdbDataLoad = new TvdbDataLoad();
        try {
            imdbDataLoad.saveShows();
            tvdbDataLoad.saveShows();
        } catch (Exception e) {
            Logger.error(e.toString());
            return ok("An error occured. Check the logs.");
        }

        return ok("Finished.");

    }

}

@@ -31,20 +31,16 @@
 ataload.
-Imdb
 DataLoad
@@ -57,28 +57,117 @@
 ataload.
-TvdbDataLoad
+parsers.AbstractShowParser;%0Aimport dataload.parsers.ImdbParser;%0Aimport dataload.provider.ImdbProvider
 ;%0Aimport
@@ -280,16 +280,96 @@
 index;%0A%0A
+import java.nio.file.Paths;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 public c
@@ -671,17 +671,16 @@
      %7D%0A%0A
-%0A
         
@@ -687,163 +687,324 @@
 Imdb
-DataLoad imdbDataLoad = new ImdbDataLoad();%0A        TvdbDataLoad tvdbDataLoad = new TvdbDataLoad();%0A        try %7B%0A            imdbDataLoad.saveShows();%0A   
+Provider imdbProvider = new ImdbProvider(Paths.get(%22app/dataload/data/release-dates.list%22));%0A        ImdbParser imdbParser = new ImdbParser(imdbProvider);%0A        List%3CAbstractShowParser%3E parsers = new ArrayList%3C%3E();%0A        parsers.add(imdbParser);%0A        DataLoad dataLoad = new DataLoad(parsers);%0A%0A        try %7B%0A
     
@@ -1012,21 +1012,20 @@
     
-tvdbD
+   d
 ataLoad.
 save
@@ -1024,12 +1024,14 @@
 oad.
-save
+import
 Show

use only imdb data for now