I seen the documentation from the book on web2py.com but I am unsure how I 
would use response.stream. Could you give me an example please? Here is the 
current code I am using.


HTML
   {{for item in printrows:}}
             {
                      title:"{{=item[0][2]}}",
                       artist:"{{=item[0][1]}}",
                      mp3:"{{=item[0][3]}}",   #jPlayer plays the song from 
this location
                    poster: "{{=item[0][4]}}"
              },
             {{pass}}

default.py

def play():
    search = Main()
artist = session.artist
song=None
      if artist and song:
            searchlastfm = search.addSongs(session.artist, session.song)
           print printrows
        countrows = 0
  if artist and not song:
        searchlastfm = search.addArtistSongs(artist)
           print "Started from the bottom", searchlastfm
          return dict(printrows=searchlastfm)
    else:
          return "nothing found"

        def addArtistSongs(self, artist):
              self.artist = artist
           mainvar = Main()
               apiPath = 
"http://ws.audioscrobbler.com/2.0/?api_key=9ab0c1e4d83f21270341c70068d02d44";
         apiMethod = "&method=artist.getTopTracks"
              # The url in which to use
              Base_URL = apiPath + apiMethod + "&artist=" + artist
           #print Base_URL
        WebSock = urllib.urlopen(Base_URL)  # Opens a 'Socket' to URL
          WebHTML = WebSock.read()            # Reads Contents of URL and 
saves to Variable
              WebSock.close()                     # Closes connection to url
         #print WebHTML
         similarTracks = 
re.findall('<track.+?>.+?<name>(.+?)</name>.+?<artist>.+?<name>(.+?)</name>.+?</artist>.+?<image
 
size="extralarge">(.+?)</image>.+?</track>', WebHTML, re.S)
           random.shuffle(similarTracks)
          print "from addArtistSongs: ", similarTracks
           artist = similarTracks[0][1]
           song = similarTracks[0][0]
             print "Searching for %s and %s" % (artist,song)
        return mainvar.addSongs(artist,song)

        def addSongs(self, artist, song):
              self.artist = artist
           self.song = song
               mainvar = Main()
               global printrows
               if len(printrows) > 15 or len(printrows) == 15:
                print "Starting over from addSongs"
                    print len(printrows)
                   printrows = []
                 print printrows
                mainvar.addSongs(artist,song)
          for similarTrackName, similarArtistName, artistArt in mainvar.
lastfmsearch(artist,song):
                       similarTrackName = similarTrackName.replace("+"," ").
replace("("," ").replace(")"," ").replace("&quot","''").replace("'","''").
replace("&amp;","and")
                  similarArtistName = similarArtistName.replace("+"," ").
replace("("," ").replace(")"," ").replace("&quot","''").replace("'","''").
replace("&amp;","and")
                row = db.executesql('SELECT * FROM lastfm Where Artist="%s" 
AND Track="%s"' % (similarArtistName, similarTrackName))
                   if row and row not in printrows:
                               row[0] = row[0] + (artistArt,)
                         printrows.append(row)
                          print len(printrows)
                   if len(printrows) == 15:
                               break
          if len(printrows) < 15:
                print "Finding Similar"
                mainvar.findSimilar()
#          print mainvar.printrows
        return printrows



On Wednesday, December 11, 2013 10:47:26 AM UTC-5, Leonel Câmara wrote:
>
> use response.stream
>
> Quarta-feira, 11 de Dezembro de 2013 0:11:46 UTC, Cliff escreveu:
>>
>> Hello.
>>
>> I am new to both python and web2py but have been playing with it a bit. I 
>> have made a simple program to listen to like artists from lastfm's API. I 
>> store my mp3s in a database: Artist/Track/File. It will go through my mp3s 
>> and find like songs and play them with jPlayer. I am stuck at playing the 
>> songs with jPlayer. It is trying to play my songs from 
>> /media/Music/artist/track.mp3 which is out of web2py's static dir. What 
>> would be the best way to allow web2py to access these files? If you had any 
>> examples that would be great.
>>
>> An example of the error: HTTP load failed with status 404. Load of media 
>> resource https://IP:8080/media/Music/mp3/Artist/Song.mp3 failed. 
>>  (removed IP and artist/song since they were not important)
>>
>> This will only be used by me and on my local server so I am not concerned 
>> with the security issues of accessing files outside of static.
>>
>>
>> Thanks!
>>
>> Cliff
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to