-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (49 loc) · 1.98 KB
/
Program.cs
File metadata and controls
58 lines (49 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Windows;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using WMPLib;
using MySql.Data;
namespace MusicDataDumper {
class Program {
static void Main(string[] args) {
var sw = File.CreateText("songdata.csv");
WindowsMediaPlayer wmpc = new WindowsMediaPlayer();
var mediaCollection = wmpc.mediaCollection.getByAttribute("MediaType", "audio");
var mediaCount = mediaCollection.count;
Console.WriteLine("Queried the media library! \n Num items in collection: {0} \t attrCount: {1}", mediaCollection.count, mediaCollection.attributeCount);
sw.WriteLine("Title,Album,Artist,TrackNumber,UserPlayCount,UserLastPlayedTime,Description,SourceURL,FileType,FileSize,Duration,CanonicalFileType");
int sinceFlush = 0;
for (int i = 0; i < mediaCount; i++) {
var mediaItem = mediaCollection.Item[i];
//var durationString = mediaItem.durationString;
//var name = mediaItem.name;
//var attributeCount = mediaItem.attributeCount;
string attr = "\"" + mediaItem.getItemInfo("Title") + "\",";
attr += "\"" + mediaItem.getItemInfo("Album") + "\",";
attr += "\"" + mediaItem.getItemInfo("Artist") + "\",";
attr += "\"" + mediaItem.getItemInfo("TrackNumber") + "\",";
attr += "\"" + mediaItem.getItemInfo("UserPlayCount") + "\",";
attr += "\"" + mediaItem.getItemInfo("UserLastPlayedTime") + "\",";
attr += "\"" + mediaItem.getItemInfo("Description") + "\",";
attr += "\"" + mediaItem.getItemInfo("SourceURL") + "\",";
attr += "\"" + mediaItem.getItemInfo("FileType") + "\",";
attr += "\"" + mediaItem.getItemInfo("FileSize") + "\",";
attr += "\"" + mediaItem.getItemInfo("Duration") + "\",";
attr += "\"" + mediaItem.getItemInfo("CanonicalFileType") + "\"\n";
if (!String.IsNullOrWhiteSpace(attr)) {
sw.Write(attr);
}
if(++sinceFlush > 50) {
sw.Flush();
sinceFlush = 0;
}
}
sw.Close();
Console.ReadKey();
}
}
}