@@ -26,6 +26,12 @@ class SigninError(MySecondLifeError):
26
26
27
27
28
28
class MySecondLife (object ):
29
+ """A wrapper around the SecondLife account pages (https://secondlife.com/my/account/)
30
+
31
+ Because SecondLife offers no API to a lot of the account-related data, we have
32
+ to make do with ugly html scraping that's bound to break horribly whenever
33
+ Linden Lab changes something.
34
+ """
29
35
username = None
30
36
password = None
31
37
@@ -37,7 +43,9 @@ def __init__(self, username, password):
37
43
self ._request_page ('http://secondlife.com/my/account/' ) # Ensures we're logged in
38
44
39
45
def _request_page (self , url ):
40
- """Requests an account-protected page"""
46
+ """Requests an account-protected page
47
+
48
+ Will perform a sign in if not yet signed in"""
41
49
br = self .br
42
50
br .open (url )
43
51
if br .title () == "OpenId transaction in progress" :
@@ -64,6 +72,7 @@ def _request_page(self, url):
64
72
return BeautifulSoup (br .response ().read ())
65
73
66
74
def _extract_friends_from_html_soup (self , soup ):
75
+ """Extract online friends from the html of the friends-online page"""
67
76
friends = []
68
77
friendsoup = soup .find_all ("div" , class_ = "main-content-body" )
69
78
assert len (friendsoup ) == 1
@@ -75,6 +84,7 @@ def _extract_friends_from_html_soup(self, soup):
75
84
return friends
76
85
77
86
def friends_online (self ):
87
+ """Return a list of online friends"""
78
88
html = self ._request_page ("https://secondlife.com/my/account/friends.php?" )
79
89
assert html .title .string == "Friends Online | Second Life"
80
90
return self ._extract_friends_from_html_soup (html )
0 commit comments