Skip to content

Commit

Permalink
tidy up comments; add README; add LICENSE
Browse files Browse the repository at this point in the history
  • Loading branch information
Grogs committed Mar 3, 2014
1 parent ca0dbad commit 35c46c8
Show file tree
Hide file tree
Showing 18 changed files with 699 additions and 67 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

27 changes: 25 additions & 2 deletions README.md
@@ -1,2 +1,25 @@
Scala Webservice for retrieving Cineworld movie listings and ratings
====
Cineworld movie listings and ratings webservice
====
The Cineworld Unlimited card is pretty awesome, but I always find myself checking every films IMDb rating. Too manual; I want to see the ratings inline. So I created a Chrome extension: [Cineworld Ratings](https://chrome.google.com/webstore/detail/cineworld-ratings/aeihmofihjacjlkecnjpoicmaaandnnc). This is the RESTful backend for that extension.


Getting Started
====
Get an API key for Rotten Tomatoes and Cineworld. Modify application.conf to include your API keys.
If you have gradle installed, type 'gradle run' in your terminal. If not, './gradlew run'.

Check it's working by browsing to the listings for [my local cinema](http://localhost:9001/api/cinema/66).

License (GPLv3)
----
Copyright (c) Greg Dorrell

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
10 changes: 0 additions & 10 deletions src/main/scala/me/gregd/cineworld/Config.scala
Expand Up @@ -9,10 +9,6 @@ import grizzled.slf4j.Logging
import collection.JavaConverters._
import com.typesafe.config.ConfigFactory

/**
* Author: Greg Dorrell
* Date: 09/06/2013
*/
object Config extends TaskSupport with Logging {
val prop = ConfigFactory.load.getString _

Expand All @@ -32,10 +28,4 @@ object Config extends TaskSupport with Logging {
frequency = 5 minutes
)


// schedule (
// task = logger.info("test"),
// frequency = 20 seconds
// )

}
Expand Up @@ -15,10 +15,6 @@ import grizzled.slf4j.Logging
import me.gregd.cineworld.Config


/**
* Author: Greg Dorrell
* Date: 11/05/2013
*/
class Cineworld(apiKey:String, implicit val imdb: IMDbDao) extends CineworldDao with Logging {
val movieCache : LoadingCache[String, List[Movie]] = {
val loader = getMoviesUncached(_:String)(imdb)
Expand Down
Expand Up @@ -3,10 +3,6 @@ package me.gregd.cineworld.dao.cineworld
import me.gregd.cineworld.domain.{Cinema, Movie, Performance}
import me.gregd.cineworld.dao.imdb.IMDbDao

/**
* Author: Greg Dorrell
* Date: 09/06/2013
*/
trait CineworldDao {
def getCinemas(): List[Cinema]
def getMovies(cinema:String)(implicit imdb: IMDbDao): List[Movie]
Expand Down
Expand Up @@ -6,9 +6,6 @@ import me.gregd.cineworld.util.caching.{JavaSerialization, LoadingCache, Databas
import JavaSerialization._
import java.io.{ByteArrayInputStream, ObjectInputStream}

/**
* Created by Greg Dorrell on 14/12/2013.
*/
class MoviesCache(val db: Database, val loader: (String) => List[Movie]) extends DatabaseCache[List[Movie]] with LoadingCache[List[Movie]] {
val cacheName = "moviesForCinema"
val deserialise = createDeserializer[List[Movie]]
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/me/gregd/cineworld/dao/imdb/IMDbDao.scala
Expand Up @@ -2,10 +2,6 @@ package me.gregd.cineworld.dao.imdb

import me.gregd.cineworld.domain.Movie

/**
* Author: Greg Dorrell
* Date: 11/05/2013
*/
trait IMDbDao {
def getId(title: String): Option[String]
def getIMDbRating(id:String) : Option[Double]
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/me/gregd/cineworld/dao/imdb/Ratings.scala
Expand Up @@ -12,10 +12,6 @@ import java.util.concurrent.TimeUnit._
import grizzled.slf4j.Logging
import java.text.NumberFormat

/**
* Author: Greg Dorrell
* Date: 11/05/2013
*/
class Ratings(rottenTomatoesApiKey:String) extends IMDbDao with Logging {
implicit val formats = DefaultFormats

Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/me/gregd/cineworld/domain/Cinema.scala
Expand Up @@ -3,10 +3,6 @@ package me.gregd.cineworld.domain
import me.gregd.cineworld.dao.cineworld.CineworldDao
import me.gregd.cineworld.dao.imdb.IMDbDao

/**
* Author: Greg Dorrell
* Date: 09/06/2013
*/
case class Cinema(
id: String,
name: String
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/me/gregd/cineworld/domain/Movie.scala
Expand Up @@ -3,10 +3,6 @@ package me.gregd.cineworld.domain
import me.gregd.cineworld.dao.imdb.{IMDbRating, Ratings, IMDbDao}
import me.gregd.cineworld.dao.cineworld.Cineworld

/**
* Author: Greg Dorrell
* Date: 11/05/2013
*/
case class Movie (
title: String,
cineworldId: String,
Expand Down
3 changes: 0 additions & 3 deletions src/main/scala/me/gregd/cineworld/domain/Performance.scala
Expand Up @@ -3,9 +3,6 @@ package me.gregd.cineworld.domain
import org.joda.time.DateTime

/**
* Author: Greg Dorrell
* Date: 11/05/2013
*
* Playing about with dates and times, always fun.
* All Cineworld cinemas are in the same time zone, so afaik I don't have to worry about it.
* I'll treat is as LocalDate (on US server) but not doing any tricky time stuff or getting times from any other sources.
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/me/gregd/cineworld/rest/CinemaService.scala
Expand Up @@ -7,10 +7,6 @@ import org.scalatra.json.NativeJsonSupport
import me.gregd.cineworld.dao.imdb.Ratings
import com.typesafe.scalalogging.slf4j.Logging

/**
* Author: Greg Dorrell
* Date: 10/06/2013
*/
class CinemaService(dao: Cineworld) extends ScalatraServlet with NativeJsonSupport with Logging {
protected implicit val jsonFormats = DefaultFormats.withBigDecimal

Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/me/gregd/cineworld/util/FilmsToWatch.scala
Expand Up @@ -2,10 +2,6 @@ package me.gregd.cineworld.util

import me.gregd.cineworld.dao.cineworld.Cineworld

/**
* Author: Greg Dorrell
* Date: 13/10/2013
*/
object FilmsToWatch extends App {

val localCinema = Cineworld.getCinemas.find(
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/me/gregd/cineworld/util/JettyBootstrap.scala
Expand Up @@ -4,10 +4,6 @@ import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
import org.scalatra.servlet.ScalatraListener

/**
* Author: Greg Dorrell
* Date: 30/05/2013
*/
object JettyBootstrap extends App {
var port = 9001
val server = new Server( port )
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/me/gregd/cineworld/util/TaskSupport.scala
Expand Up @@ -2,10 +2,6 @@ package me.gregd.cineworld.util

import java.util.{TimerTask, Timer}

/**
* Author: Greg Dorrell
* Date: 09/08/2013
*/
trait TaskSupport {

lazy val defaultTimer = TaskSupport.timer
Expand Down
Expand Up @@ -6,9 +6,6 @@ import Q.interpolation
import java.util.Date
import java.sql.{Blob, Timestamp}

/**
* Created by Greg Dorrell on 14/12/2013.
*/
abstract class DatabaseCache[T] {

val cacheName: String
Expand Down
Expand Up @@ -3,9 +3,6 @@ package me.gregd.cineworld.util.caching
import java.io.{ByteArrayOutputStream, ObjectOutputStream, ByteArrayInputStream, ObjectInputStream}
import me.gregd.cineworld.domain.Movie

/**
* Created by Greg Dorrell on 14/12/2013.
*/
object JavaSerialization {

def createSerializer[T]: (T) => Array[Byte] = { t =>
Expand Down
@@ -1,8 +1,5 @@
package me.gregd.cineworld.util.caching

/**
* Created by Greg Dorrell on 14/12/2013.
*/
trait LoadingCache[T] { self: DatabaseCache[T] =>

val loader: String => T
Expand Down

0 comments on commit 35c46c8

Please sign in to comment.