Permalink
Browse files

Creating the project

  • Loading branch information...
0 parents commit 891c8fa504945a92ff3380ecc68b9ecc6203db8b @oleander committed Feb 5, 2011
Binary file not shown.
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
@@ -0,0 +1,5 @@
+--color
+-fs
+-Ilib
+-Ispec
+--require spec_helper
@@ -0,0 +1,5 @@
+# gem 'jopenssl'
+source "http://rubygems.org"
+gem 'jruby-rack', '~> 1.0.6.beta'
+# Specify your gem's dependencies in undertexter.gemspec
+gemspec
@@ -0,0 +1,4 @@
+require 'warbler'
+Warbler::Task.new
+task :war => "asset:packager:build_all"
+# require 'rawr'
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+MovishScript.run("The.Big.Bang.Theory.S04E14.The.Thespian.Catalyst.HDTV.XviD-FQM.avi", "/Users/linus/Downloads")
@@ -0,0 +1,62 @@
+# encoding: UTF-8
+
+require 'unpack'
+require 'ruby-growl'
+require 'movie_searcher'
+require 'undertexter'
+
+# Dir["#{File.expand_path('../vendor/cache', __FILE__)}/**"].map { |dir| File.directory?(lib = "#{dir}/lib") ? lib : dir }.each do |folder|
+# $LOAD_PATH.unshift(folder)
+# end
+
+module MovishScript
+ def self.run(name, dir)
+ # gem install unpack ruby-growl movie_searcher undertexter
+
+ # Om inga parametrar skickades med så gör vi inget
+ abort if dir.nil? or name.nil?
+
+ growl = Growl.new("localhost", "ruby-growl", ["ruby-growl Notification"])
+ growl.notify("ruby-growl Notification", "Movish", "Vänta...")
+
+ # Hela länkvägen till filen som laddades hem
+ full_path = "#{dir}/#{name}"
+
+ # Absoluta länk-vägen till filen/mappen
+ path = File.directory?(full_path) ? full_path : File.dirname(full_path)
+
+ # Titlen på den nerladdade filen/mappen
+ title = name
+
+ # Packar upp filerna, såvida det var en mapp vi laddade hem
+ files = File.directory?(full_path) ? Unpack.runner!(full_path) : []
+
+ # Meddelar användaren om att nerladdningen är uppackad, om något fanns att packa upp
+ growl.notify("ruby-growl Notification", "Uppackat!", title) if files.any?
+
+ # Hämtar filmen från IMDB
+ movie = MovieSearcher.find_by_download(full_path)
+
+ # Avbryter om vi inte hittade någon film
+ if movie.nil?
+ growl.notify("ruby-growl Notification", "Inget hittades", title); abort
+ end
+
+ # Hämtar undertexten
+ subtitle = Undertexter.find(movie.imdb_id).based_on(title)
+
+ # Avbryter om vi inte hittade någon undertext
+ if subtitle.nil?
+ growl.notify("ruby-growl Notification", "Ingen undertext hittades", movie.title); abort
+ end
+
+ # Laddar ner undertexten
+ file = subtitle.download!
+
+ # Packar upp undertexten och skickar och skickar innehållet till den nerladdade mappen
+ Unpack.it!(file: file, to: path) unless file.nil?
+
+ # Meddelar användaren att allt gick bra
+ growl.notify("ruby-growl Notification", "Undertext hittades", subtitle.title)
+ end
+end
@@ -0,0 +1,3 @@
+module MovishScript
+ VERSION = "0.0.1"
+end
@@ -0,0 +1,28 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "movish_script"
+ s.version = '1'
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["TODO: Write your name"]
+ s.email = ["TODO: Write your email address"]
+ s.homepage = ""
+ s.summary = %q{TODO: Write a gem summary}
+ s.description = %q{TODO: Write a gem description}
+
+ s.rubyforge_project = "movish_script"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ s.add_dependency('rest-client')
+ s.add_dependency('unpack')
+ s.add_dependency('ruby-growl')
+ s.add_dependency('movie_searcher')
+ s.add_dependency('undertexter')
+ s.add_dependency('jruby-openssl')
+ s.add_development_dependency('rspec')
+end
Binary file not shown.
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe MovishScript do
+ it "should work" do
+ lambda {
+ MovishScript.run("The.Big.Bang.Theory.S04E14.The.Thespian.Catalyst.HDTV.XviD-FQM.avi", "/Users/linus/Downloads")
+ }.should raise_error(SystemExit)
+ end
+end
@@ -0,0 +1,6 @@
+require 'rspec'
+require "#{File.dirname(__FILE__)}/../lib/movish_script"
+
+RSpec.configure do |config|
+ config.mock_with :rspec
+end

0 comments on commit 891c8fa

Please sign in to comment.