- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
Latest commit
58 lines (49 loc) · 1.98 KB
/
Copy pathProgram.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
usingSystem;
usingSystem.Windows;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Threading.Tasks;
usingSystem.IO;
usingWMPLib;
usingMySql.Data;
namespaceMusicDataDumper{
classProgram{
staticvoidMain(string[]args){
varsw=File.CreateText("songdata.csv");
WindowsMediaPlayerwmpc=newWindowsMediaPlayer();
varmediaCollection=wmpc.mediaCollection.getByAttribute("MediaType","audio");
varmediaCount=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");
intsinceFlush=0;
for(inti=0;i<mediaCount;i++){
varmediaItem=mediaCollection.Item[i];
//var durationString = mediaItem.durationString;
//var name = mediaItem.name;
//var attributeCount = mediaItem.attributeCount;
stringattr="\""+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();
}
}
}