コード例 #1
0
ファイル: JsonAdapter.py プロジェクト: hoprocker/wefunk-api
def getShowsAsJson(tot=HARD_LIMIT, from_show=None):
    try: tot=int(tot)
    except: tot = HARD_LIMIT
    try: from_show = int(from_show)
    except: from_show = ShowBusiness.getLatestShowNum()

    shows = ShowBusiness.getShowsBefore(from_show, min(tot, HARD_LIMIT))
    return map(ShowBusiness.showToObj, shows)
コード例 #2
0
ファイル: JsonAdapter.py プロジェクト: hoprocker/wefunk-api
def getShowTracksAsJson(from_show):
    if from_show in [IntType,LongType]:
        from_show = ShowBusiness.getShow(from_show)
    tracks = map(lambda x: {'artist':x['artist'], 
                            'title':x['title'],
                            'start_mspos':x['start_mspos']
                            }, ShowBusiness.getShowTracks(from_show))
    return json.dumps(tracks)
コード例 #3
0
ファイル: Test.py プロジェクト: hoprocker/wefunk-api
def test_showDatastoreAccess():
    cnt = ShowBusiness.getShowCount()
    assert type(cnt) == IntType

    sh = ShowBusiness.addShow("asdf", 3, date(10, 2, 4), "asdfasdf", "asdfasfd", 10, [])
    assert ShowBusiness.getShowCount() == cnt+1
    db.delete(sh)
    assert ShowBusiness.getShowCount() == cnt
コード例 #4
0
ファイル: Test.py プロジェクト: hoprocker/wefunk-api
def test_refreshShowIndex():
    show_cnt = ShowBusiness.getShowCount()

    newnum = ShowScrape.refreshShowIndex(650)
    assert ShowBusiness.getShowCount() == newnum+show_cnt

    ## do it twice and make sure it doesn't repeat
    ShowScrape.refreshShowIndex(600)
    assert ShowBusiness.getShowCount() == newnum+show_cnt
コード例 #5
0
ファイル: Test.py プロジェクト: hoprocker/wefunk-api
def test_scrapeAndStore():

    show_info = ShowScrape.parseShowPage(open(SHOW_PAGE,"r").read())
    assert len(show_info["tracks"]) > 0

    sh_cnt = ShowBusiness.getShowCount()
    show = ShowBusiness.addShow(**show_info)
    assert ShowBusiness.getShowCount() == sh_cnt+1
    assert ShowBusiness.getShow(show_info["number"]) != None
    assert ShowBusiness.getShowTrackCount(show_info["number"]) > 0
コード例 #6
0
ファイル: ShowScrape.py プロジェクト: hoprocker/wefunk-api
def pullShowInfo(show):
    if ShowBusiness.getShow(show["number"]) != None:
        return False  ## already in datastore
    show_url = urllib.basejoin(SHOW_URL, show['href'])

    logging.debug("adding show to queue: %s" % (show_url,))
    taskqueue.add(url='/admin/update/%s/' % (urllib.quote_plus(show_url),))
    return True
コード例 #7
0
ファイル: wefunk_main.py プロジェクト: hoprocker/wefunk-api
def clear_all_shows():
    return "%s shows cleared" % (str(ShowBusiness.clearAllShows()),)
コード例 #8
0
ファイル: wefunk_main.py プロジェクト: hoprocker/wefunk-api
def del_show(shownum):
    return ShowBusiness.deleteShow(shownum)
コード例 #9
0
ファイル: wefunk_main.py プロジェクト: hoprocker/wefunk-api
def get_tracks_for_show(show):
    return ",".join(ShowBusiness.getShowTracks(show))
コード例 #10
0
ファイル: ShowScrape.py プロジェクト: hoprocker/wefunk-api
def addShowFromPage(show_url):
    show_url = urllib.unquote_plus(show_url)
    show_info = parseShowPage(fetchPage(show_url))
    ShowBusiness.addShow(**show_info)