Method: StatsCollect::Locations::MySpace#execute
- Defined in:
- lib/StatsCollect/Locations/MySpace.rb
#execute(oStatsProxy, iConf, iLstObjects, iLstCategories) ⇒ Object
Execute the plugin. This method has to add the stats and errors to the proxy. It can filter only objects and categories given. It has access to its configuration.
- Parameters
-
oStatsProxy (StatsProxy): The stats proxy to be used to populate stats
-
iConf (map<Symbol,Object>): The configuration associated to this plugin
-
iLstObjects (list<String>): List of objects to filter (can be empty for all)
-
iLstCategories (list<String>): List of categories to filter (can be empty for all)
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 |
# File 'lib/StatsCollect/Locations/MySpace.rb', line 22 def execute(oStatsProxy, iConf, iLstObjects, iLstCategories) require 'mechanize' lMechanizeAgent = Mechanize.new # Set a specific user agent, as myspace will treat our agent as a mobile one lMechanizeAgent.user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13' # Get the login page lLoginForm = lMechanizeAgent.get('http://www.myspace.com/redirector?dest=/home').forms[2] lLoginForm.Email = iConf[:LoginEMail] lLoginForm.Password = iConf[:LoginPassword] # Submit to get to the home page lMechanizeAgent.submit(lLoginForm, lLoginForm..first) if (oStatsProxy.is_object_included?('Global')) if (oStatsProxy.is_category_included?('Comments')) getProfile(oStatsProxy, lMechanizeAgent) end if ((oStatsProxy.is_category_included?('Friends')) or (oStatsProxy.is_category_included?('Visits'))) getDashboard(oStatsProxy, lMechanizeAgent) end if (oStatsProxy.is_category_included?('Friends list')) getFriendsList(oStatsProxy, lMechanizeAgent) end end if (oStatsProxy.is_category_included?('Song plays')) getSongs(oStatsProxy, lMechanizeAgent) end if ((oStatsProxy.is_category_included?('Video plays')) or (oStatsProxy.is_category_included?('Video comments')) or (oStatsProxy.is_category_included?('Video likes')) or (oStatsProxy.is_category_included?('Video rating'))) getVideos(oStatsProxy, lMechanizeAgent) end if ((oStatsProxy.is_category_included?('Blog reads')) or (oStatsProxy.is_category_included?('Blog likes'))) getBlogs(oStatsProxy, lMechanizeAgent, iConf) end end |