StatsCollect 0.2.0.20110830 → 0.3.0.20120314
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +3 -1
- data/ChangeLog +15 -0
- data/LICENSE +1 -1
- data/README +2 -5
- data/ReleaseInfo +8 -8
- data/bin/StatsCollect.rb +3 -3
- data/lib/StatsCollect/Backends/MySQL.rb +63 -63
- data/lib/StatsCollect/Backends/Terminal.rb +43 -43
- data/lib/StatsCollect/Locations/AddThis.rb +7 -7
- data/lib/StatsCollect/Locations/CSV.rb +9 -9
- data/lib/StatsCollect/Locations/Facebook.rb +7 -7
- data/lib/StatsCollect/Locations/FacebookArtist.rb +7 -7
- data/lib/StatsCollect/Locations/FacebookLike.rb +7 -7
- data/lib/StatsCollect/Locations/GoogleGroup.rb +10 -10
- data/lib/StatsCollect/Locations/GoogleSearch.rb +6 -6
- data/lib/StatsCollect/Locations/MySpace.rb +43 -43
- data/lib/StatsCollect/Locations/RB.rb +10 -10
- data/lib/StatsCollect/Locations/ReverbNation.rb +34 -34
- data/lib/StatsCollect/Locations/Tweets.rb +7 -7
- data/lib/StatsCollect/Locations/Twitter.rb +11 -11
- data/lib/StatsCollect/Locations/Youtube.rb +33 -49
- data/lib/StatsCollect/Notifiers/Custom.rb +3 -3
- data/lib/StatsCollect/Notifiers/LogFile.rb +4 -4
- data/lib/StatsCollect/Notifiers/None.rb +3 -3
- data/lib/StatsCollect/Notifiers/SendMail.rb +3 -3
- data/lib/StatsCollect/Stats.rb +81 -81
- data/lib/StatsCollect/StatsOrdersProxy.rb +3 -3
- data/lib/StatsCollect/StatsProxy.rb +28 -28
- metadata +24 -12
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -14,7 +14,7 @@ module StatsCollect
|
|
14
14
|
# It can filter only objects and categories given.
|
15
15
|
# It has access to its configuration.
|
16
16
|
#
|
17
|
-
# Parameters
|
17
|
+
# Parameters::
|
18
18
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
19
19
|
# * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
|
20
20
|
# * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
|
@@ -22,36 +22,36 @@ module StatsCollect
|
|
22
22
|
def execute(oStatsProxy, iConf, iLstObjects, iLstCategories)
|
23
23
|
if (!iConf[:Files].empty?)
|
24
24
|
# Get the list of categories, locations and objects
|
25
|
-
lCategories = oStatsProxy.
|
26
|
-
lObjects = oStatsProxy.
|
27
|
-
lLocations = oStatsProxy.
|
25
|
+
lCategories = oStatsProxy.get_categories
|
26
|
+
lObjects = oStatsProxy.get_objects
|
27
|
+
lLocations = oStatsProxy.get_locations
|
28
28
|
iConf[:Files].each do |iFileName|
|
29
29
|
lLstStats = nil
|
30
30
|
File.open(iFileName, 'r') do |iFile|
|
31
31
|
lLstStats = eval(iFile.read)
|
32
32
|
end
|
33
33
|
lMissingIDs = false
|
34
|
-
|
34
|
+
log_info "Read #{lLstStats.size} stats from RB file."
|
35
35
|
lLstStats.each do |ioStatInfo|
|
36
36
|
iCheckExistenceBeforeAdd, iTimeStamp, iLocationName, iObjectName, iCategoryName, iValue = ioStatInfo
|
37
37
|
ioStatInfo[1] = DateTime.strptime(iTimeStamp, iConf[:DateTimeFormat])
|
38
38
|
if (iConf[:IDsMustExist])
|
39
39
|
if (lLocations[iLocationName] == nil)
|
40
|
-
|
40
|
+
log_warn "Unknown location from RB file #{iFileName}: #{iLocationName}"
|
41
41
|
lMissingIDs = true
|
42
42
|
end
|
43
43
|
if (lObjects[iObjectName] == nil)
|
44
|
-
|
44
|
+
log_warn "Unknown object from RB file #{iFileName}: #{iObjectName}"
|
45
45
|
lMissingIDs = true
|
46
46
|
end
|
47
47
|
if (lCategories[iCategoryName] == nil)
|
48
|
-
|
48
|
+
log_warn "Unknown category from RB file #{iFileName}: #{iCategoryName}"
|
49
49
|
lMissingIDs = true
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
if (!lMissingIDs)
|
54
|
-
oStatsProxy.
|
54
|
+
oStatsProxy.add_stats_list(lLstStats)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -14,7 +14,7 @@ module StatsCollect
|
|
14
14
|
# It can filter only objects and categories given.
|
15
15
|
# It has access to its configuration.
|
16
16
|
#
|
17
|
-
# Parameters
|
17
|
+
# Parameters::
|
18
18
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
19
19
|
# * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
|
20
20
|
# * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
|
@@ -29,28 +29,28 @@ module StatsCollect
|
|
29
29
|
lHomePage = lMechanizeAgent.submit(lLoginForm, lLoginForm.buttons.first)
|
30
30
|
# Get the user id, as it will be necessary for further requests
|
31
31
|
lUserID = lHomePage.uri.to_s.match(/^http:\/\/www\.reverbnation\.com\/artist\/control_room\/(\d*)$/)[1]
|
32
|
-
if ((oStatsProxy.
|
33
|
-
(oStatsProxy.
|
34
|
-
(oStatsProxy.
|
35
|
-
(oStatsProxy.
|
36
|
-
(oStatsProxy.
|
32
|
+
if ((oStatsProxy.is_category_included?('Song plays')) or
|
33
|
+
(oStatsProxy.is_category_included?('Song downloads')) or
|
34
|
+
(oStatsProxy.is_category_included?('Song play ratio')) or
|
35
|
+
(oStatsProxy.is_category_included?('Song likes')) or
|
36
|
+
(oStatsProxy.is_category_included?('Song dislikes')))
|
37
37
|
getPlays(oStatsProxy, lMechanizeAgent, lUserID)
|
38
38
|
end
|
39
|
-
if (oStatsProxy.
|
39
|
+
if (oStatsProxy.is_category_included?('Video plays'))
|
40
40
|
getVideos(oStatsProxy, lMechanizeAgent, lUserID)
|
41
41
|
end
|
42
|
-
if ((oStatsProxy.
|
43
|
-
((oStatsProxy.
|
44
|
-
(oStatsProxy.
|
45
|
-
(oStatsProxy.
|
46
|
-
(oStatsProxy.
|
42
|
+
if ((oStatsProxy.is_object_included?('Global')) and
|
43
|
+
((oStatsProxy.is_category_included?('Chart position genre')) or
|
44
|
+
(oStatsProxy.is_category_included?('Chart position global')) or
|
45
|
+
(oStatsProxy.is_category_included?('Band equity')) or
|
46
|
+
(oStatsProxy.is_category_included?('Friends'))))
|
47
47
|
getReport(oStatsProxy, lMechanizeAgent, lUserID)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
# Get the plays statistics
|
52
52
|
#
|
53
|
-
# Parameters
|
53
|
+
# Parameters::
|
54
54
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
55
55
|
# * *iMechanizeAgent* (_Mechanize_): The agent reading pages
|
56
56
|
# * *iUserID* (_String_): The ReverbNation user ID
|
@@ -66,22 +66,22 @@ module StatsCollect
|
|
66
66
|
lNbrSongPlays = Integer(lNodeContents[3].content)
|
67
67
|
lNbrSongDownloads = Integer(lNodeContents[4].content)
|
68
68
|
lPlayRatio = Integer(lNodeContents[5].content.match(/^(\d*)%$/)[1])
|
69
|
-
lMatch = lNodeContents[6].content.match(/^(\d*)\/(\d*)$/)
|
70
|
-
lNbrLikes = Integer(lMatch[1])
|
71
|
-
lNbrDislikes = Integer(lMatch[2])
|
72
|
-
oStatsProxy.
|
73
|
-
oStatsProxy.
|
74
|
-
oStatsProxy.
|
75
|
-
oStatsProxy.
|
76
|
-
oStatsProxy.
|
69
|
+
# lMatch = lNodeContents[6].content.match(/^(\d*)\/(\d*)$/)
|
70
|
+
# lNbrLikes = Integer(lMatch[1])
|
71
|
+
# lNbrDislikes = Integer(lMatch[2])
|
72
|
+
oStatsProxy.add_stat(lSongTitle, 'Song plays', lNbrSongPlays)
|
73
|
+
oStatsProxy.add_stat(lSongTitle, 'Song downloads', lNbrSongDownloads)
|
74
|
+
oStatsProxy.add_stat(lSongTitle, 'Song play ratio', lPlayRatio)
|
75
|
+
# oStatsProxy.add_stat(lSongTitle, 'Song likes', lNbrLikes)
|
76
|
+
# oStatsProxy.add_stat(lSongTitle, 'Song dislikes', lNbrDislikes)
|
77
77
|
lLstSongsRead << lSongTitle
|
78
78
|
end
|
79
|
-
|
79
|
+
log_debug "#{lLstSongsRead.size} songs read: #{lLstSongsRead.join(', ')}"
|
80
80
|
end
|
81
81
|
|
82
82
|
# Get the videos statistics
|
83
83
|
#
|
84
|
-
# Parameters
|
84
|
+
# Parameters::
|
85
85
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
86
86
|
# * *iMechanizeAgent* (_Mechanize_): The agent reading pages
|
87
87
|
# * *iUserID* (_String_): The ReverbNation user ID
|
@@ -95,15 +95,15 @@ module StatsCollect
|
|
95
95
|
lNodeContents = iSongNode.css('td')
|
96
96
|
lVideoTitle = lNodeContents[1].children[0].content
|
97
97
|
lNbrVideoPlays = Integer(lNodeContents[3].content)
|
98
|
-
oStatsProxy.
|
98
|
+
oStatsProxy.add_stat(lVideoTitle, 'Video plays', lNbrVideoPlays)
|
99
99
|
lLstVideosRead << lVideoTitle
|
100
100
|
end
|
101
|
-
|
101
|
+
log_debug "#{lLstVideosRead.size} videos read: #{lLstVideosRead.join(', ')}"
|
102
102
|
end
|
103
103
|
|
104
104
|
# Get the report statistics
|
105
105
|
#
|
106
|
-
# Parameters
|
106
|
+
# Parameters::
|
107
107
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
108
108
|
# * *iMechanizeAgent* (_Mechanize_): The agent reading pages
|
109
109
|
# * *iUserID* (_String_): The ReverbNation user ID
|
@@ -127,7 +127,7 @@ module StatsCollect
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
if (lChartPositionGenre == nil)
|
130
|
-
|
130
|
+
log_err "Unable to get the chart positions: #{lReportPage.root}"
|
131
131
|
else
|
132
132
|
lBandEquityScore = nil
|
133
133
|
lNbrFriends = nil
|
@@ -146,14 +146,14 @@ module StatsCollect
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
if (lBandEquityScore == nil)
|
149
|
-
|
149
|
+
log_err "Unable to get the band equity score: #{lReportPage.root}"
|
150
150
|
elsif (lNbrFriends == nil)
|
151
|
-
|
151
|
+
log_err "Unable to get the number of friends: #{lReportPage.root}"
|
152
152
|
else
|
153
|
-
oStatsProxy.
|
154
|
-
oStatsProxy.
|
155
|
-
oStatsProxy.
|
156
|
-
oStatsProxy.
|
153
|
+
oStatsProxy.add_stat('Global', 'Chart position genre', lChartPositionGenre)
|
154
|
+
oStatsProxy.add_stat('Global', 'Chart position global', lChartPositionGlobal)
|
155
|
+
oStatsProxy.add_stat('Global', 'Band equity', lBandEquityScore)
|
156
|
+
oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -14,7 +14,7 @@ module StatsCollect
|
|
14
14
|
# It can filter only objects and categories given.
|
15
15
|
# It has access to its configuration.
|
16
16
|
#
|
17
|
-
# Parameters
|
17
|
+
# Parameters::
|
18
18
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
19
19
|
# * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
|
20
20
|
# * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
|
@@ -23,23 +23,23 @@ module StatsCollect
|
|
23
23
|
require 'mechanize'
|
24
24
|
lMechanizeAgent = Mechanize.new
|
25
25
|
# Get the number of likes from Facebook
|
26
|
-
if (oStatsProxy.
|
26
|
+
if (oStatsProxy.is_category_included?('Tweets'))
|
27
27
|
lFailedObjects = []
|
28
28
|
iConf[:Objects].each do |iObject|
|
29
|
-
if (oStatsProxy.
|
29
|
+
if (oStatsProxy.is_object_included?(iObject))
|
30
30
|
lTweetsData = lMechanizeAgent.get_file("http://urls.api.twitter.com/1/urls/count.json?url=#{iObject}").gsub(/:/,'=>')
|
31
31
|
if (lTweetsData.match(/Unable to access URL counting services/) != nil)
|
32
32
|
# An error occurred: we can try again
|
33
|
-
|
33
|
+
log_err "Error while fetching Tweets for #{iObject}: #{lTweetsData}"
|
34
34
|
lFailedObjects << iObject
|
35
35
|
else
|
36
36
|
lNbrTweets = eval(lTweetsData)['count']
|
37
|
-
oStatsProxy.
|
37
|
+
oStatsProxy.add_stat(iObject, 'Tweets', lNbrTweets)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
if (!lFailedObjects.empty?)
|
42
|
-
oStatsProxy.
|
42
|
+
oStatsProxy.add_recoverable_order(lFailedObjects, ['Tweets'])
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -14,17 +14,17 @@ module StatsCollect
|
|
14
14
|
# It can filter only objects and categories given.
|
15
15
|
# It has access to its configuration.
|
16
16
|
#
|
17
|
-
# Parameters
|
17
|
+
# Parameters::
|
18
18
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
19
19
|
# * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
|
20
20
|
# * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
|
21
21
|
# * *iLstCategories* (<em>list<String></em>): List of categories to filter (can be empty for all)
|
22
22
|
def execute(oStatsProxy, iConf, iLstObjects, iLstCategories)
|
23
|
-
if ((oStatsProxy.
|
24
|
-
((oStatsProxy.
|
25
|
-
(oStatsProxy.
|
26
|
-
(oStatsProxy.
|
27
|
-
(oStatsProxy.
|
23
|
+
if ((oStatsProxy.is_object_included?('Global')) and
|
24
|
+
((oStatsProxy.is_category_included?('Following')) or
|
25
|
+
(oStatsProxy.is_category_included?('Followers')) or
|
26
|
+
(oStatsProxy.is_category_included?('Lists followers')) or
|
27
|
+
(oStatsProxy.is_category_included?('Tweets'))))
|
28
28
|
require 'mechanize'
|
29
29
|
lMechanizeAgent = Mechanize.new
|
30
30
|
lProfilePage = lMechanizeAgent.get("http://twitter.com/#{iConf[:Name]}")
|
@@ -32,10 +32,10 @@ module StatsCollect
|
|
32
32
|
lNbrFollowers = Integer(lProfilePage.root.css('span#follower_count').first.content.strip)
|
33
33
|
lNbrLists = Integer(lProfilePage.root.css('span#lists_count').first.content.strip)
|
34
34
|
lNbrTweets = Integer(lProfilePage.root.css('span#update_count').first.content.strip)
|
35
|
-
oStatsProxy.
|
36
|
-
oStatsProxy.
|
37
|
-
oStatsProxy.
|
38
|
-
oStatsProxy.
|
35
|
+
oStatsProxy.add_stat('Global', 'Following', lNbrFollowing)
|
36
|
+
oStatsProxy.add_stat('Global', 'Followers', lNbrFollowers)
|
37
|
+
oStatsProxy.add_stat('Global', 'Lists followers', lNbrLists)
|
38
|
+
oStatsProxy.add_stat('Global', 'Tweets', lNbrTweets)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -14,7 +14,7 @@ module StatsCollect
|
|
14
14
|
# It can filter only objects and categories given.
|
15
15
|
# It has access to its configuration.
|
16
16
|
#
|
17
|
-
# Parameters
|
17
|
+
# Parameters::
|
18
18
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
19
19
|
# * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
|
20
20
|
# * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
|
@@ -30,31 +30,27 @@ module StatsCollect
|
|
30
30
|
else
|
31
31
|
lMechanizeAgent.submit(lLoginForm, lLoginForm.buttons.first).meta.first.click
|
32
32
|
end
|
33
|
-
if ((oStatsProxy.
|
34
|
-
(oStatsProxy.
|
35
|
-
(oStatsProxy.
|
36
|
-
(oStatsProxy.
|
37
|
-
(oStatsProxy.
|
33
|
+
if ((oStatsProxy.is_category_included?('Video plays')) or
|
34
|
+
(oStatsProxy.is_category_included?('Video likes')) or
|
35
|
+
(oStatsProxy.is_category_included?('Video dislikes')) or
|
36
|
+
(oStatsProxy.is_category_included?('Video comments')) or
|
37
|
+
(oStatsProxy.is_category_included?('Video responses')))
|
38
38
|
getVideos(oStatsProxy, lMechanizeAgent)
|
39
39
|
end
|
40
|
-
if ((oStatsProxy.
|
41
|
-
((oStatsProxy.
|
42
|
-
(oStatsProxy.
|
40
|
+
if ((oStatsProxy.is_object_included?('Global')) and
|
41
|
+
((oStatsProxy.is_category_included?('Visits')) or
|
42
|
+
(oStatsProxy.is_category_included?('Followers'))))
|
43
43
|
getOverview(oStatsProxy, lMechanizeAgent)
|
44
44
|
end
|
45
|
-
if ((oStatsProxy.
|
46
|
-
(oStatsProxy.
|
47
|
-
getFriends(oStatsProxy, lMechanizeAgent)
|
48
|
-
end
|
49
|
-
if ((oStatsProxy.isObjectIncluded?('Global')) and
|
50
|
-
(oStatsProxy.isCategoryIncluded?('Following')))
|
45
|
+
if ((oStatsProxy.is_object_included?('Global')) and
|
46
|
+
(oStatsProxy.is_category_included?('Following')))
|
51
47
|
getSubscriptions(oStatsProxy, lMechanizeAgent)
|
52
48
|
end
|
53
49
|
end
|
54
50
|
|
55
51
|
# Get the videos statistics
|
56
52
|
#
|
57
|
-
# Parameters
|
53
|
+
# Parameters::
|
58
54
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
59
55
|
# * *iMechanizeAgent* (_Mechanize_): The agent reading pages
|
60
56
|
def getVideos(oStatsProxy, iMechanizeAgent)
|
@@ -63,25 +59,24 @@ module StatsCollect
|
|
63
59
|
lLstVideosRead = []
|
64
60
|
lVideosPage.root.css('li.vm-video-item').each do |iVideoNode|
|
65
61
|
lVideoTitle = iVideoNode.css('div.vm-video-title a').first.content
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
oStatsProxy.
|
73
|
-
oStatsProxy.
|
74
|
-
oStatsProxy.
|
75
|
-
oStatsProxy.
|
76
|
-
oStatsProxy.addStat(lVideoTitle, 'Video dislikes', lNbrDislikes)
|
62
|
+
lNbrPlays = Integer(iVideoNode.css('div.vm-video-metrics span.video-view-count span.vm-video-metric-value')[0].content.strip)
|
63
|
+
lNbrLikes = Integer(iVideoNode.css('div.vm-video-metrics span.video-likes-count span.vm-video-metric-value')[0].content.strip)
|
64
|
+
lNbrDislikes = Integer(iVideoNode.css('div.vm-video-metrics span.video-dislikes-count span.vm-video-metric-value')[0].content.strip)
|
65
|
+
lNbrComments = Integer(iVideoNode.css('div.vm-video-metrics span.video-comments span.vm-video-metric-value')[0].content.strip)
|
66
|
+
#lNbrResponses = Integer(lMetricNodes[2].content.strip)
|
67
|
+
oStatsProxy.add_stat(lVideoTitle, 'Video plays', lNbrPlays)
|
68
|
+
oStatsProxy.add_stat(lVideoTitle, 'Video comments', lNbrComments)
|
69
|
+
#oStatsProxy.add_stat(lVideoTitle, 'Video responses', lNbrResponses)
|
70
|
+
oStatsProxy.add_stat(lVideoTitle, 'Video likes', lNbrLikes)
|
71
|
+
oStatsProxy.add_stat(lVideoTitle, 'Video dislikes', lNbrDislikes)
|
77
72
|
lLstVideosRead << lVideoTitle
|
78
73
|
end
|
79
|
-
|
74
|
+
log_debug "#{lLstVideosRead.size} videos read: #{lLstVideosRead.join(', ')}"
|
80
75
|
end
|
81
76
|
|
82
77
|
# Get the overview statistics
|
83
78
|
#
|
84
|
-
# Parameters
|
79
|
+
# Parameters::
|
85
80
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
86
81
|
# * *iMechanizeAgent* (_Mechanize_): The agent reading pages
|
87
82
|
def getOverview(oStatsProxy, iMechanizeAgent)
|
@@ -103,35 +98,24 @@ module StatsCollect
|
|
103
98
|
end
|
104
99
|
end
|
105
100
|
if (lNbrVisits == nil)
|
106
|
-
|
101
|
+
log_err "Unable to get number of visits: #{lOverviewPage.content}"
|
107
102
|
elsif (lNbrFollowers == nil)
|
108
|
-
|
103
|
+
log_err "Unable to get number of followers: #{lOverviewPage.content}"
|
109
104
|
else
|
110
|
-
oStatsProxy.
|
111
|
-
oStatsProxy.
|
105
|
+
oStatsProxy.add_stat('Global', 'Visits', lNbrVisits)
|
106
|
+
oStatsProxy.add_stat('Global', 'Followers', lNbrFollowers)
|
112
107
|
end
|
113
108
|
end
|
114
109
|
|
115
110
|
# Get the friends statistics
|
116
111
|
#
|
117
|
-
# Parameters
|
118
|
-
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
119
|
-
# * *iMechanizeAgent* (_Mechanize_): The agent reading pages
|
120
|
-
def getFriends(oStatsProxy, iMechanizeAgent)
|
121
|
-
lOverviewPage = iMechanizeAgent.get('http://www.youtube.com/profile?view=friends')
|
122
|
-
lNbrFriends = Integer(lOverviewPage.root.xpath('//span[@name="channel-box-item-count"]').first.content)
|
123
|
-
oStatsProxy.addStat('Global', 'Friends', lNbrFriends)
|
124
|
-
end
|
125
|
-
|
126
|
-
# Get the friends statistics
|
127
|
-
#
|
128
|
-
# Parameters:
|
112
|
+
# Parameters::
|
129
113
|
# * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
|
130
114
|
# * *iMechanizeAgent* (_Mechanize_): The agent reading pages
|
131
115
|
def getSubscriptions(oStatsProxy, iMechanizeAgent)
|
132
|
-
lOverviewPage = iMechanizeAgent.get('http://www.youtube.com/profile
|
133
|
-
lNbrFollowing = Integer(lOverviewPage.root.
|
134
|
-
oStatsProxy.
|
116
|
+
lOverviewPage = iMechanizeAgent.get('http://www.youtube.com/profile')
|
117
|
+
lNbrFollowing = Integer(lOverviewPage.root.css('div.header-stats span.stat-value').first.content.strip)
|
118
|
+
oStatsProxy.add_stat('Global', 'Following', lNbrFollowing)
|
135
119
|
end
|
136
120
|
|
137
121
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -11,10 +11,10 @@ module StatsCollect
|
|
11
11
|
|
12
12
|
# Send a given notification
|
13
13
|
#
|
14
|
-
# Parameters
|
14
|
+
# Parameters::
|
15
15
|
# * *iConf* (<em>map<Symbol,Object></em>): The notifier config
|
16
16
|
# * *iMessage* (_String_): Message to send
|
17
|
-
def
|
17
|
+
def send_notification(iConf, iMessage)
|
18
18
|
iConf[:SendCode].call(iMessage)
|
19
19
|
end
|
20
20
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010 -
|
2
|
+
# Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
|
3
3
|
# Licensed under the terms specified in LICENSE file. No warranty is provided.
|
4
4
|
#++
|
5
5
|
|
@@ -11,11 +11,11 @@ module StatsCollect
|
|
11
11
|
|
12
12
|
# Send a given notification
|
13
13
|
#
|
14
|
-
# Parameters
|
14
|
+
# Parameters::
|
15
15
|
# * *iConf* (<em>map<Symbol,Object></em>): The notifier config
|
16
16
|
# * *iMessage* (_String_): Message to send
|
17
|
-
def
|
18
|
-
File.open(iConf[:
|
17
|
+
def send_notification(iConf, iMessage)
|
18
|
+
File.open(iConf[:log_file], (iConf[:Append] == true) ? 'a' : 'w') do |oFile|
|
19
19
|
oFile.write(iMessage)
|
20
20
|
end
|
21
21
|
end
|