Class: Anstaendig::AbstractAgent
- Inherits:
-
Object
- Object
- Anstaendig::AbstractAgent
- Defined in:
- lib/anstaendig/abstractagent.rb
Overview
This interface describes download agents.
Direct Known Subclasses
Defined Under Namespace
Classes: NoSuchQualityException
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, quality = :high) ⇒ AbstractAgent
constructor
If an agent does not set @filename, it would be the current time and date.
-
#recode ⇒ Object
Contains the subshell command to recode the video to a Vorbis/Theora encoded video in an OGG container.
-
#rip ⇒ Object
Contains the subshell command to rip the video stream.
-
#run ⇒ Object
Calls the ripping process after substitution of certain characters in the filename generated by the agent.
-
#userAgent ⇒ Object
Return the user agent which is sent on stream retrieval.
Constructor Details
#initialize(url, quality = :high) ⇒ AbstractAgent
If an agent does not set @filename, it would be the current time and date.
15 16 17 |
# File 'lib/anstaendig/abstractagent.rb', line 15 def initialize( url, quality = :high ) @filename = Time.now.to_i end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
6 7 8 |
# File 'lib/anstaendig/abstractagent.rb', line 6 def filename @filename end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/anstaendig/abstractagent.rb', line 6 def url @url end |
Instance Method Details
#recode ⇒ Object
Contains the subshell command to recode the video to a Vorbis/Theora encoded video in an OGG container. Meant to be overloaded by the agent if necessary.
38 39 40 |
# File 'lib/anstaendig/abstractagent.rb', line 38 def recode `ffmpeg -i "#{@filename}" -acodec libvorbis -vcodec libtheora "#{@filename}.ogg"` end |
#rip ⇒ Object
Contains the subshell command to rip the video stream. mplayer by default. Meant to be overloaded by the agent if necessary.
31 32 33 |
# File 'lib/anstaendig/abstractagent.rb', line 31 def rip `mplayer -user-agent "#{userAgent}" -dumpstream -dumpfile "#{@filename}" "#{@url}"` end |
#run ⇒ Object
Calls the ripping process after substitution of certain characters in the filename generated by the agent.
21 22 23 24 25 26 27 |
# File 'lib/anstaendig/abstractagent.rb', line 21 def run [ '/', '"', "'" ].each do |char| @filename.gsub!( char, '' ) end rip end |
#userAgent ⇒ Object
Return the user agent which is sent on stream retrieval. Meant to be overloaded by the agent if necessary.
44 45 46 |
# File 'lib/anstaendig/abstractagent.rb', line 44 def userAgent "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2) Gecko/20100323 Namoroka/3.6.2" end |