コード例 #1
0
ファイル: myspace2rdf.py プロジェクト: apassant/motools
    def get_friends(self):
        ''' get list of top friends '''
        #friendTupleList = scrapePageTuple(self.html, friendDict)
        friendUIDs = scrapePageWhile(self.html, uris.friendTag[0], uris.friendTag[1])
        friendNames = scrapePageWhile(self.html, uris.friendNameTag[0], uris.friendNameTag[1])
        friendPics = scrapePageWhile(self.html, uris.friendPicTag[0], uris.friendPicTag[1])

        # TODO fix this horrible hack - for non-artists, they appear here as well
        #if len(friendUIDs) != len(friendNames):
        #    friendUIDs = friendUIDs[1:]

        for i in range(len(friendUIDs)):
            currentUID = friendUIDs[i]
            if currentUID.isdigit():
                friend = mopy.foaf.Person(uris.dbtune+'uid/' + str(friendUIDs[i]))
            else:
                friend = mopy.foaf.Person(uris.dbtune+str(friendUIDs[i]))
            try:
                friend.name.set(friendNames[i])
            except IndexError:
                pass
            try:
                img = mopy.foaf.Image(friendPics[i])
                friend.depiction.add(img)
            except:
                pass


            #self.subject.knows.add(friend)

            # self.subject.knows.add(friend)
            # since when did this happen??? mopy wont take foaf:knows as a prop of mo:MusicArtist

            self.subject.topFriend.add(friend)
            self.mi.add(friend)
コード例 #2
0
ファイル: myspace2rdf.py プロジェクト: apassant/motools
 def __get_artist_id(self):
     '''attempt to find via scrape of page the internal artist number.'''
     ids = scrapePageWhile(self.html, uris.artistIDtag[0], uris.artistIDtag[1])
     for i in ids:
         if i.isdigit():
             self.artistID = i
             return True
     return False
コード例 #3
0
ファイル: myspace2rdf.py プロジェクト: apassant/motools
 def __get_playlist_id(self):
     """attempts to find via scrape of the internal identifier of an artist's playlist of songs"""
     # make sure we get a digit and not some crap - maybe should to regex
     ids = scrapePageWhile(self.html, uris.playlistIDtag[0], uris.playlistIDtag[1])
     for i in ids:
         if i.isdigit():
             self.playlistID = i
             return True
     return False