This commit is contained in:
2024-05-23 17:51:06 +08:00
parent f6582be3f0
commit bc34a4f839
3 changed files with 173 additions and 60 deletions

View File

@@ -236,6 +236,9 @@ def generate_audio_report(pdb: PlaybackReportingDb, itemMap, rowMap, albumMap,
data = pdb.get_activitys(offset, itemType='Audio', userId=userId,
startTime=startTime, endTime=endTime)
albumCountMap = {}
trackCountMap = {}
artistCountMap = {}
alArtCountMap = {}
with CSVFile(join(output, "history.csv")) as his:
his.write(_("Id"), _("Date"), _("Time"), _("Name"), _("Artists"), _("Album"), _("Album artists"), _("Duration"), _("Duration") + _("(seconds)"), _("Original item id"), _("Item id"), _("Play duration"), _("Play duration") + _("(seconds)"), _("Record content"), _("Client name"), _("Device name"), _("Playback method"), _("Play count")) # noqa: E501
while len(data) > 0:
@@ -283,6 +286,43 @@ def generate_audio_report(pdb: PlaybackReportingDb, itemMap, rowMap, albumMap,
albumCountMap[album] = {'count': 1,
'play_count': play_count,
'duration': play_duration}
if itemId in trackCountMap:
tmp = trackCountMap[itemId]
tmp['count'] += 1
tmp['play_count'] += play_count
tmp['duration'] += play_duration
else:
trackCountMap[itemId] = {'count': 1,
'play_count': play_count,
'duration': play_duration}
if artists:
for art in artists.split("|"):
ar = art.strip()
if ar in artistCountMap:
tmp = artistCountMap[ar]
tmp['count'] += 1
tmp['play_count'] += play_count
tmp['duration'] += play_duration
else:
artistCountMap[ar] = {'count': 1,
'play_count': play_count,
'duration': play_duration}
if album_artists:
if 'type' in item:
arts = album_artists.split("|")
else:
arts = album_artists.split(",")
for art in arts:
ar = art.strip()
if ar in alArtCountMap:
tmp = alArtCountMap[ar]
tmp['count'] += 1
tmp['play_count'] += play_count
tmp['duration'] += play_duration
else:
alArtCountMap[ar] = {'count': 1,
'play_count': play_count,
'duration': play_duration}
offset += len(data)
data = pdb.get_activitys(offset, itemType='Audio', userId=userId,
startTime=startTime, endTime=endTime)
@@ -316,3 +356,52 @@ def generate_audio_report(pdb: PlaybackReportingDb, itemMap, rowMap, albumMap,
if date.endswith("-01-01 00:00:00"):
date = None
al.write(album, album_artists, artists, count['count'], count['play_count'], format_duration(count['duration']), count['duration'], format_duration(duration), duration, year, date, publisher, itemId) # noqa: E501
with CSVFile(join(output, 'track.csv')) as tr:
tr.write(_("Name"), _("Artists"), _("Record count"), _("Play count"), _("Play duration"), _("Play duration") + _("(seconds)"), _("Duration"), _("Duration") + _("(seconds)"), _("Album"), _("Album artists"), _("Genres"), _("Track no"), _("Disc no"), _("Year"), _("Publish date"), _("Publisher"), _("Item id")) # noqa: E501
for itemId in trackCountMap:
item = itemMap[itemId]
count = trackCountMap[itemId]
name = ''
artists = ''
album = ''
album_artists = ''
genres = ''
track = None
disc = None
year = None
date = None
publisher = None
duration = None
if 'type' in item:
name = item['Name']
artists = item['Artists']
album = item['Album']
album_artists = item['AlbumArtists']
genres = item['Genres']
track = item['IndexNumber']
disc = item['ParentIndexNumber']
duration = item['RunTimeTicks'] / TIME_BASE
year = item['ProductionYear']
date = item['PremiereDate']
publisher = item['Studios']
else:
it = ITEMNAME_PATTERN.match(item['ItemName']).groupdict()
name = it['track']
if it['album'] != NOT_KNOWN:
album = it['album']
if it['album_artist'] != NOT_KNOWN:
album_artists = it['album_artist']
if year and date:
if date.endswith("-01-01 00:00:00"):
date = None
tr.write(name, artists, count['count'], count['play_count'], format_duration(count['duration']), count['duration'], format_duration(duration), duration, album, album_artists, genres, track, disc, year, date, publisher, itemId) # noqa: E501
with CSVFile(join(output, 'artist.csv')) as ar:
ar.write(_("Name"), _("Record count"), _("Play count"), _("Play duration"), _("Play duration") + _("(seconds)")) # noqa: E501
for artist in artistCountMap:
count = artistCountMap[artist]
ar.write(artist, count['count'], count['play_count'], format_duration(count['duration']), count['duration']) # noqa: E501
with CSVFile(join(output, 'album_artist.csv')) as alAr:
alAr.write(_("Name"), _("Record count"), _("Play count"), _("Play duration"), _("Play duration") + _("(seconds)")) # noqa: E501
for artist in alArtCountMap:
count = alArtCountMap[artist]
alAr.write(artist, count['count'], count['play_count'], format_duration(count['duration']), count['duration']) # noqa: E501

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: jellyfinStats 1.0\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-05-16 10:47+0800\n"
"POT-Creation-Date: 2024-05-23 16:35+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -17,31 +17,31 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: __main__.py:20
#: __main__.py:11
msgid "The path to config file."
msgstr ""
#: __main__.py:21
#: __main__.py:12
msgid "The path to playback_reporting.db"
msgstr ""
#: __main__.py:22
#: __main__.py:13
msgid "The path to library.db"
msgstr ""
#: __main__.py:23
#: __main__.py:14
msgid "The path to jellyfin data directory."
msgstr ""
#: __main__.py:24
#: __main__.py:15
msgid "The directory for output files."
msgstr ""
#: __main__.py:25
#: __main__.py:16
msgid "Specify maximum items to display in one page."
msgstr ""
#: __main__.py:26
#: __main__.py:17
msgid "The path to jellyfin.db"
msgstr ""
@@ -117,90 +117,102 @@ msgstr ""
msgid "Please input album name:"
msgstr ""
#: audio.py:240
#: audio.py:241
msgid "Id"
msgstr ""
#: audio.py:240
#: audio.py:241
msgid "Date"
msgstr ""
#: audio.py:240
#: audio.py:241
msgid "Time"
msgstr ""
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Name"
msgstr ""
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Artists"
msgstr ""
#: audio.py:240
#: audio.py:241 audio.py:330
msgid "Album"
msgstr ""
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Album artists"
msgstr ""
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Duration"
msgstr ""
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "(seconds)"
msgstr ""
#: audio.py:240
#: audio.py:241
msgid "Original item id"
msgstr ""
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Item id"
msgstr ""
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Play duration"
msgstr ""
#: audio.py:240
#: audio.py:241
msgid "Record content"
msgstr ""
#: audio.py:240
#: audio.py:241
msgid "Client name"
msgstr ""
#: audio.py:240
#: audio.py:241
msgid "Device name"
msgstr ""
#: audio.py:240
#: audio.py:241
msgid "Playback method"
msgstr ""
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Play count"
msgstr ""
#: audio.py:290
#: audio.py:300 audio.py:330
msgid "Record count"
msgstr ""
#: audio.py:290
#: audio.py:300 audio.py:330
msgid "Year"
msgstr ""
#: audio.py:290
#: audio.py:300 audio.py:330
msgid "Publish date"
msgstr ""
#: audio.py:290
#: audio.py:300 audio.py:330
msgid "Publisher"
msgstr ""
#: audio.py:330
msgid "Genres"
msgstr ""
#: audio.py:330
msgid "Track no"
msgstr ""
#: audio.py:330
msgid "Disc no"
msgstr ""
#: cache.py:23
msgid "Unsupported version: "
msgstr ""
@@ -239,7 +251,7 @@ msgstr ""
msgid "Last page"
msgstr ""
#: utils.py:97
#: utils.py:98
#, python-format
msgid "%i day"
msgstr ""

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: jellyfinStats 1.0\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-05-16 10:47+0800\n"
"POT-Creation-Date: 2024-05-23 16:35+0800\n"
"PO-Revision-Date: 2024-05-15 10:20+0800\n"
"Last-Translator: mhy <[email protected]>\n"
"Language-Team: Chinese (simplified) <[email protected]>\n"
@@ -16,31 +16,31 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: __main__.py:20
#: __main__.py:11
msgid "The path to config file."
msgstr "配置文件位置。"
#: __main__.py:21
#: __main__.py:12
msgid "The path to playback_reporting.db"
msgstr "playback_reporting.db 文件位置。"
#: __main__.py:22
#: __main__.py:13
msgid "The path to library.db"
msgstr "library.db 文件位置。"
#: __main__.py:23
#: __main__.py:14
msgid "The path to jellyfin data directory."
msgstr "Jellyfin 数据目录位置。"
#: __main__.py:24
#: __main__.py:15
msgid "The directory for output files."
msgstr "输出目录位置。"
#: __main__.py:25
#: __main__.py:16
msgid "Specify maximum items to display in one page."
msgstr "指定一页可以显示的最大条目数。"
#: __main__.py:26
#: __main__.py:17
msgid "The path to jellyfin.db"
msgstr "jellyfin.db 文件位置。"
@@ -116,90 +116,102 @@ msgstr "请输入标题:"
msgid "Please input album name:"
msgstr "请输入专辑名称:"
#: audio.py:240
#: audio.py:241
msgid "Id"
msgstr "ID"
#: audio.py:240
#: audio.py:241
msgid "Date"
msgstr "日期"
#: audio.py:240
#: audio.py:241
msgid "Time"
msgstr "时间"
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Name"
msgstr "名称"
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Artists"
msgstr "艺术家"
#: audio.py:240
#: audio.py:241 audio.py:330
msgid "Album"
msgstr "专辑"
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Album artists"
msgstr "专辑艺术家"
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Duration"
msgstr "时长"
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "(seconds)"
msgstr "(秒)"
#: audio.py:240
#: audio.py:241
msgid "Original item id"
msgstr "原项目ID"
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Item id"
msgstr "项目ID"
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Play duration"
msgstr "播放时长"
#: audio.py:240
#: audio.py:241
msgid "Record content"
msgstr "记录内容"
#: audio.py:240
#: audio.py:241
msgid "Client name"
msgstr "客户端名称"
#: audio.py:240
#: audio.py:241
msgid "Device name"
msgstr "设备名称"
#: audio.py:240
#: audio.py:241
msgid "Playback method"
msgstr "播放方式"
#: audio.py:240 audio.py:290
#: audio.py:241 audio.py:300 audio.py:330
msgid "Play count"
msgstr "播放次数"
#: audio.py:290
#: audio.py:300 audio.py:330
msgid "Record count"
msgstr "记录次数"
#: audio.py:290
#: audio.py:300 audio.py:330
msgid "Year"
msgstr "年份"
#: audio.py:290
#: audio.py:300 audio.py:330
msgid "Publish date"
msgstr "发布日期"
#: audio.py:290
#: audio.py:300 audio.py:330
msgid "Publisher"
msgstr "发布者"
#: audio.py:330
msgid "Genres"
msgstr "风格"
#: audio.py:330
msgid "Track no"
msgstr "轨道号"
#: audio.py:330
msgid "Disc no"
msgstr "光盘号"
#: cache.py:23
msgid "Unsupported version: "
msgstr "不支持的版本:"
@@ -238,7 +250,7 @@ msgstr "下一页"
msgid "Last page"
msgstr "最后一页"
#: utils.py:97
#: utils.py:98
#, python-format
msgid "%i day"
msgstr "%i 天"