rhythmbox_count_rating_integrator.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:migrate-itunes-to-rhythmbox 作者: phauer 项目源码 文件源码
def create_itunes_statistic_dict(itunes_songs: Dict[int, Song], itunes_library_root: str) -> Dict[str, SongStatistic]:
    """use canonical location as a common identifier. returns dict[canonical_location -> SongStatistic(play_count, rating)]"""
    dict = {}
    for itunes_song in itunes_songs.values():
        if itunes_song.location_escaped is not None:
            count = itunes_song.play_count
            last_played = itunes_song.lastplayed
            last_played_timestamp = calendar.timegm(last_played) if last_played is not None else None
            itunes_rating = itunes_song.rating
            mapped_rating = ITUNES_TO_RHYTHMBOX_RATINGS_MAP[itunes_rating]
            location = itunes_song.location_escaped
            canonical_location = create_canonical_location_for_itunes_location(location, itunes_library_root)
            dict[canonical_location] = SongStatistic(count, mapped_rating, last_played_timestamp)
        else:
            print("   Can't assign the track [{} - {}] because there is no file location defined. It's probably a remote file."
                  .format(itunes_song.artist, itunes_song.name))
    return dict
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号