-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreceiver.rb
63 lines (48 loc) · 1.44 KB
/
receiver.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Receivers get the final download link and cookies
# and handle the actual act of downloading it.
module Receiver
# Base class for receivers that creates the download button.
class Base
# The name of the receiver.
attr_reader :name
# The button which will trigger this receiver.
attr_reader :button
def initialize(name)
@name = name
@button = Gtk::Button.new()
end
# Updates the button text based on the #online? status
# of the receiver.
def update_button()
if self.online?
@button.label = "\u21A1 with #{@name}"
@button.sensitive = true
else
@button.label = "#{@name} is offline"
@button.sensitive = false
end
end
# Returns an entry wrapper for the given entry.
def wrap(entry)
wrapper = EntryWrapper.new
wrapper.entry = entry
wrapper.receiver = self
return wrapper
end
# Adds the given link to the receiver.
def add(link, file_name = nil, cookies = nil)
$log.debug("adding #{link} as #{file_name} to #{@name}")
self.handle(link, file_name, cookies)
end
end
# Stores an entry and the receiver used to download it.
class EntryWrapper
# The downloaded entry.
attr_accessor :entry
# The receiver used to download it.
attr_accessor :receiver
end
end
require_relative './receiver/aria.rb'
require_relative './receiver/mplayer.rb'
require_relative './receiver/vlc.rb'