当前位置: 首页>>代码示例>>Java>>正文


Java ScrobbleData类代码示例

本文整理汇总了Java中de.umass.lastfm.scrobble.ScrobbleData的典型用法代码示例。如果您正苦于以下问题:Java ScrobbleData类的具体用法?Java ScrobbleData怎么用?Java ScrobbleData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScrobbleData类属于de.umass.lastfm.scrobble包,在下文中一共展示了ScrobbleData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scrobble

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
public static ScrobbleResult scrobble(ScrobbleData scrobbleData, Session session) {
	Map<String, String> params = new HashMap<String, String>();
	// required params
	params.put("artist", scrobbleData.getArtist());
	params.put("track", scrobbleData.getTrack());
	params.put("timestamp", String.valueOf(scrobbleData.getTimestamp()));
	// optional params
	MapUtilities.nullSafePut(params, "album", scrobbleData.getAlbum());
	MapUtilities.nullSafePut(params, "albumArtist", scrobbleData.getAlbumArtist());
	MapUtilities.nullSafePut(params, "duration", scrobbleData.getDuration());
	MapUtilities.nullSafePut(params, "mbid", scrobbleData.getMusicBrainzId());
	MapUtilities.nullSafePut(params, "trackNumber", scrobbleData.getTrackNumber());
	MapUtilities.nullSafePut(params, "streamId", scrobbleData.getStreamId());
	params.put("chosenByUser", StringUtilities.convertFromBoolean(scrobbleData.isChosenByUser()));

	Result result = Caller.getInstance().call("track.scrobble", session, params);
	return convertToScrobbleResults(result, ScrobbleResultType.SINGLE_SCROBBLE).get(0);
}
 
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:19,代码来源:Track.java

示例2: scrobble

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
public List<ScrobbleResult> scrobble(Session session) throws IOException {
	File file = new File(cacheDir, SUBMISSIONS_FILE);
	List<ScrobbleResult> result = new ArrayList<ScrobbleResult>();
	if (file.exists()) {
		BufferedReader r = new BufferedReader(new FileReader(file));
		List<ScrobbleData> list = new ArrayList<ScrobbleData>(50);
		String line;
		while ((line = r.readLine()) != null) {
			ScrobbleData d = decodeScrobbleData(line);
			list.add(d);
			if (list.size() == 50) {
				result.addAll(Track.scrobble(list, session));
				list.clear();
			}
		}
		if (list.size() > 0)
			result.addAll(Track.scrobble(list, session));
		r.close();
		FileWriter w = new FileWriter(file);
		w.close();
	}
	return result;
}
 
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:24,代码来源:FileSystemCache.java

示例3: scrobbleTracks

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
/**
 * Submits the specified scrobbles to the Last.fm API for the current user.
 *
 * @param scrobbles the list of scrobbles to submit. Must be 50 or fewer items.
 * @param callback the callback which will be invoked with the results of the submissions, with a
 *     list of {@link Result} as the message payload.
 */
public void scrobbleTracks(List<Scrobble> scrobbles, Handler.Callback callback) {
  Preconditions.checkArgument(
      scrobbles.size() <= 50, "Cannot submit more than 50 scrobbles at once");
  final ScrobbleData[] scrobbleData = new ScrobbleData[scrobbles.size()];

  for (int i = 0; i < scrobbles.size(); i++) {
    Scrobble scrobble = scrobbles.get(i);
    com.peterjosling.scroball.Track track = scrobble.track();
    ScrobbleData data = new ScrobbleData(track.artist(), track.track(), scrobble.timestamp());
    if (track.album().isPresent()) {
      data.setAlbum(track.album().get());
    }
    if (track.albumArtist().isPresent()) {
      data.setAlbumArtist(track.albumArtist().get());
    }
    if (track.duration().isPresent() && track.duration().get() > 0) {
      data.setDuration((int) (track.duration().get() / 1000));
    }
    scrobbleData[i] = data;
  }

  new ScrobbleTracksTask(api, session, callback).execute(scrobbleData);
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:31,代码来源:LastfmClient.java

示例4: scrobble

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
public static ScrobbleResult scrobble(ScrobbleData scrobbleData, Session session) {
    Map<String, String> params = new HashMap<String, String>();
    // required params
    params.put("artist", scrobbleData.getArtist());
    params.put("track", scrobbleData.getTrack());
    params.put("timestamp", String.valueOf(scrobbleData.getTimestamp()));
    // optional params
    MapUtilities.nullSafePut(params, "album", scrobbleData.getAlbum());
    MapUtilities.nullSafePut(params, "albumArtist", scrobbleData.getAlbumArtist());
    MapUtilities.nullSafePut(params, "duration", scrobbleData.getDuration());
    MapUtilities.nullSafePut(params, "mbid", scrobbleData.getMusicBrainzId());
    MapUtilities.nullSafePut(params, "trackNumber", scrobbleData.getTrackNumber());
    MapUtilities.nullSafePut(params, "streamId", scrobbleData.getStreamId());
    params.put("chosenByUser", StringUtilities.convertFromBoolean(scrobbleData.isChosenByUser()));

    Result result = Caller.getInstance().call("track.scrobble", session, params);
    return convertToScrobbleResults(result, ScrobbleResultType.SINGLE_SCROBBLE).get(0);
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:19,代码来源:Track.java

示例5: scrobble

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
public List<ScrobbleResult> scrobble(Session session) throws IOException {
    File file = new File(cacheDir, SUBMISSIONS_FILE);
    List<ScrobbleResult> result = new ArrayList<ScrobbleResult>();
    if (file.exists()) {
        BufferedReader r = new BufferedReader(new FileReader(file));
        List<ScrobbleData> list = new ArrayList<ScrobbleData>(50);
        String line;
        while ((line = r.readLine()) != null) {
            ScrobbleData d = decodeScrobbleData(line);
            list.add(d);
            if (list.size() == 50) {
                result.addAll(Track.scrobble(list, session));
                list.clear();
            }
        }
        if (list.size() > 0)
            result.addAll(Track.scrobble(list, session));
        r.close();
        FileWriter w = new FileWriter(file);
        w.close();
    }
    return result;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:24,代码来源:FileSystemCache.java

示例6: updateNowPlaying

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
public static ScrobbleResult updateNowPlaying(ScrobbleData scrobbleData, Session session) {
	Map<String, String> params = new HashMap<String, String>();
	// required params
	params.put("artist", scrobbleData.getArtist());
	params.put("track", scrobbleData.getTrack());
	// optional params
	MapUtilities.nullSafePut(params, "album", scrobbleData.getAlbum());
	MapUtilities.nullSafePut(params, "albumArtist", scrobbleData.getAlbumArtist());
	MapUtilities.nullSafePut(params, "duration", scrobbleData.getDuration());
	MapUtilities.nullSafePut(params, "mbid", scrobbleData.getMusicBrainzId());
	MapUtilities.nullSafePut(params, "trackNumber", scrobbleData.getTrackNumber());
	MapUtilities.nullSafePut(params, "streamId", scrobbleData.getStreamId());
	Result result = Caller.getInstance().call("track.updateNowPlaying", session, params);
	return convertToScrobbleResults(result, ScrobbleResultType.NOW_PLAYING).get(0);
}
 
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:16,代码来源:Track.java

示例7: cacheScrobbles

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
public void cacheScrobbles(ScrobbleData... scrobbles) {
	createCache();
	try {
		BufferedWriter w = new BufferedWriter(new FileWriter(new File(cacheDir, SUBMISSIONS_FILE), true));
		for (ScrobbleData scrobble : scrobbles) {
			w.append(encodeScrobbleData(scrobble));
			w.newLine();
		}
		w.close();
	} catch (IOException e) {
		// huh ?
		//	e.printStackTrace();
	}
}
 
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:15,代码来源:FileSystemCache.java

示例8: encodeScrobbleData

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
private static String encodeScrobbleData(ScrobbleData d) {
	String artist = StringUtilities.encode(d.getArtist());
	String track = StringUtilities.encode(d.getTrack());
	String album = StringUtilities.encode(d.getAlbum());
	String albumArtist = StringUtilities.encode(d.getAlbumArtist());
	return String.format("%s;%s;%s;%s;%s;%s;%s;%s;%s;%b", artist, track, d.getTimestamp(), d.getDuration(), album, albumArtist, d.getMusicBrainzId(),
			d.getTrackNumber(), d.getStreamId(), d.isChosenByUser());
}
 
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:9,代码来源:FileSystemCache.java

示例9: scrobbleSpotifyTrack

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
public void scrobbleSpotifyTrack(Track track) {
    // start session if not started
    if (mLastFmSession == null) {

        UserPreferences prefs = UserPreferences.getInstance(SpotifyTvApplication.getInstance().getApplicationContext());
        String lastFmUsername = prefs.getLastFmUsername();
        String lastFmPassword = prefs.getLastFmPassword();

        // if not set, don't do anything
        if (TextUtils.isEmpty(lastFmUsername) || TextUtils.isEmpty(lastFmPassword)) {
            return;
        }

        startLastFmSession(lastFmUsername, lastFmPassword);
    }

    if (mLastFmSession == null) {
        // if the session is still null, that means that we couldn't authenticate the user on last.fm
        // (e.g. username/password is incorrect)
        return;
    }

    int now = (int) (System.currentTimeMillis() / 1000);
    ScrobbleData scrobbleData = new ScrobbleData(track.artists.get(0).name, track.name, now);

    de.umass.lastfm.Track.updateNowPlaying(scrobbleData, mLastFmSession);
    de.umass.lastfm.Track.scrobble(scrobbleData, mLastFmSession);
}
 
开发者ID:sregg,项目名称:spotify-tv,代码行数:29,代码来源:LastFmApi.java

示例10: updateNowPlaying

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
public static ScrobbleResult updateNowPlaying(ScrobbleData scrobbleData, Session session) {
    Map<String, String> params = new HashMap<String, String>();
    // required params
    params.put("artist", scrobbleData.getArtist());
    params.put("track", scrobbleData.getTrack());
    // optional params
    MapUtilities.nullSafePut(params, "album", scrobbleData.getAlbum());
    MapUtilities.nullSafePut(params, "albumArtist", scrobbleData.getAlbumArtist());
    MapUtilities.nullSafePut(params, "duration", scrobbleData.getDuration());
    MapUtilities.nullSafePut(params, "mbid", scrobbleData.getMusicBrainzId());
    MapUtilities.nullSafePut(params, "trackNumber", scrobbleData.getTrackNumber());
    MapUtilities.nullSafePut(params, "streamId", scrobbleData.getStreamId());
    Result result = Caller.getInstance().call("track.updateNowPlaying", session, params);
    return convertToScrobbleResults(result, ScrobbleResultType.NOW_PLAYING).get(0);
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:16,代码来源:Track.java

示例11: cacheScrobbles

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
public void cacheScrobbles(ScrobbleData... scrobbles) {
    createCache();
    try {
        BufferedWriter w = new BufferedWriter(new FileWriter(new File(cacheDir, SUBMISSIONS_FILE), true));
        for (ScrobbleData scrobble : scrobbles) {
            w.append(encodeScrobbleData(scrobble));
            w.newLine();
        }
        w.close();
    } catch (IOException e) {
        // huh ?
        //  e.printStackTrace();
    }
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:15,代码来源:FileSystemCache.java

示例12: encodeScrobbleData

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
private static String encodeScrobbleData(ScrobbleData d) {
    String artist = StringUtilities.encode(d.getArtist());
    String track = StringUtilities.encode(d.getTrack());
    String album = StringUtilities.encode(d.getAlbum());
    String albumArtist = StringUtilities.encode(d.getAlbumArtist());
    return String.format("%s;%s;%s;%s;%s;%s;%s;%s;%s;%b", artist, track, d.getTimestamp(), d.getDuration(), album, albumArtist, d.getMusicBrainzId(),
            d.getTrackNumber(), d.getStreamId(), d.isChosenByUser());
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:9,代码来源:FileSystemCache.java

示例13: decodeScrobbleData

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
private static ScrobbleData decodeScrobbleData(String s) {
	String[] parts = s.split(";", 10);
	return new ScrobbleData(StringUtilities.decode(parts[0]), StringUtilities.decode(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]),
			StringUtilities.decode(parts[4]), StringUtilities.decode(parts[5]), parts[6], Integer.parseInt(parts[7]), parts[8], Boolean.parseBoolean(parts[9]));
}
 
开发者ID:kawaiiDango,项目名称:pScrobbler,代码行数:6,代码来源:FileSystemCache.java

示例14: scrobble

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
/**
 * @see Track#scrobble(List, Session)
 */
public List<ScrobbleResult> scrobble(List<ScrobbleData> scrobbleData, Session session) {
  return Track.scrobble(scrobbleData, session);
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:7,代码来源:LastfmApi.java

示例15: decodeScrobbleData

import de.umass.lastfm.scrobble.ScrobbleData; //导入依赖的package包/类
private static ScrobbleData decodeScrobbleData(String s) {
    String[] parts = s.split(";", 10);
    return new ScrobbleData(StringUtilities.decode(parts[0]), StringUtilities.decode(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]),
            StringUtilities.decode(parts[4]), StringUtilities.decode(parts[5]), parts[6], Integer.parseInt(parts[7]), parts[8], Boolean.parseBoolean(parts[9]));
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:6,代码来源:FileSystemCache.java


注:本文中的de.umass.lastfm.scrobble.ScrobbleData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。