Skip to content

Commit

Permalink
Update TODO, add broken initial implementation of podcast, hash app s…
Browse files Browse the repository at this point in the history
…tate

by the library directory
  • Loading branch information
anaisbetts committed May 27, 2008
1 parent de801fb commit 9ffdea0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 13 deletions.
10 changes: 4 additions & 6 deletions TODO
Expand Up @@ -4,6 +4,7 @@ Done:
* Fix exec script
* FFmpeg/libfaac/whatever from source, statically compiled
* Daemon mode (frontend/backend separation)
* Simple queue of files to encode

Pre 0.1:
(All done!)
Expand All @@ -13,20 +14,17 @@ Pre 0.1:

0.2:
* Investigate what other encoders (Handbrake et al.) are doing
* Rails daemon running video podcasts to local machine, advertise using Zeroconf
* Merb daemon running video podcasts to local machine
* Advertise using Zeroconf
* OSX disk image
* Use Taglib to write tag information

0.5:
* Qt4 GUI
* Use Taglib to read/write tag information, and present in podcast entries

0.8:
* Works in Win32
* Completely platform-appropriate behavior (follows Windows conventions on Win32, etc)
* Windows installer

Future:
* Simple queue of files to encode
* Monitoring FFmpeg output (without confusing rb!)
* Daemon control interface, script to kick off encoder run
* Dir change notifications on Linux, OSX
Expand Down
21 changes: 20 additions & 1 deletion app/controllers/podcast.rb
@@ -1,5 +1,24 @@
require 'feed_tools'

class Podcast < Application
def index
render
app = Yikes.instance

feed = FeedTools::Feed.new
feed.title = "Yikes Video Feed of #{app.state.library}"
feed.author.name = "Yikes"
feed.link = "http://github.com/xpaulbettsx/yikes"

app.state.get_finished_items.each do |item|
f = FeedTools::FeedItem.new

f.title = "#{Pathname.new(item.path).basename}"
f.link = "http://foobar.com"
f.content = "I am a test"

feed.entries << f
end

render feed.build_xml("rss", 2.0), :layout => false
end
end
2 changes: 1 addition & 1 deletion lib/main.rb
Expand Up @@ -131,7 +131,7 @@ def run
# Reset our logging level because option parsing changed it
self.level = $logging_level

load_state(File.join(Platform.settings_dir, 'state.yaml'))
load_state(File.join(Platform.settings_dir, 'state.yaml'), results[:library])

# Actually do stuff
unless results[:background]
Expand Down
33 changes: 28 additions & 5 deletions lib/state.rb
Expand Up @@ -31,31 +31,41 @@

include GetText

# TODO: We may make this customizable later
ItemsInFinishedList = 30

# This module contains the thread-safe state that we share with the web service thread
# TODO: The name 'state' is completely retarded
module ApplicationState
attr_accessor :state

def load_state(path)
def load_state(path, library)
real_lib = Pathname.new(library).realpath.to_s
begin
@state = YAML::load(File.read(path))
# We hold a different State class for every library path
@full_state = YAML::load(File.read(path))
@state = @full_state[real_lib] || (@full_state[real_lib] = State.new(library))
rescue
@state = State.new
@full_state = { real_lib => State.new(library) }
@state = @full_state[real_lib]
end
end

def save_state(path)
File.open(path, 'w') {|f| f.write(YAML::dump(@state)) }
File.open(path, 'w') {|f| f.write(YAML::dump(@full_state)) }
end

class State
attr_accessor :encoded_queue
attr_accessor :to_encode_queue
attr_accessor :library

def initialize
def initialize(library)
@encoded_queue = []
@to_encode_queue = []
@encoded_queue_lock = Mutex.new
@to_encode_queue_lock = Mutex.new
@library = library
end

def add_to_queue(items, prepend = false)
Expand Down Expand Up @@ -98,8 +108,21 @@ def add_to_finished_list(item)
item.finished_at = Time.now
@encoded_queue_lock.synchronize {
@encoded_queue << item
break if @encoded_queue.length <= ItemsInFinishedList

@encoded_queue = @encoded_queue.last(ItemsInFinishedList)
}
end

def get_finished_items
# Make a shallow copy so we don't have to hold the lock for so long
ret = nil
@encoded_queue_lock.synchronize {
ret = Array.new(@encoded_queue)
}

ret
end
end
end

Expand Down

0 comments on commit 9ffdea0

Please sign in to comment.