قسمت اول این مطلب را
در اینجا میتوانید مطالعه کنید. از سه سال قبل تا به این تاریخ، فرمت زیرنویسهای این سایت به صورت JSON تغییر پیدا کردهاست و یک چنین ساختار جدیدی را دارد:
{
"userIsAuthorizedForCourseTranscripts": false,
"modules": [
{
"title": "Course Overview",
"clips": [
{
"title": "Course Overview",
"playerParameters": "author=scott-allen&name=aspdotnet-core-1-0-fundamentals-m0&mode=live&clip=0&course=aspdotnet-core-1-0-fundamentals",
"transcripts": [ ]
}
]
},
{
"title": "Building Your First ASP.NET Core Application",
"clips": [
{
"title": "Introduction",
"playerParameters": "author=scott-allen&name=aspdotnet-core-1-0-fundamentals-m1&mode=live&clip=0&course=aspdotnet-core-1-0-fundamentals",
"transcripts": [
{
"displayTime": 0.0,
"text": "Hi! This is Scott, and this course will help you build your first application with ASP.NET Core."
},
{
"displayTime": 7.0,
"text": "In this course, we'll be using Visual Studio and the new ASP.NET Framework to build a web application that"
}
]
}
]
}
]
}
که اگر بخواهیم کلاسهای معادل آنرا تشکیل دهیم، به ساختار زیر خواهیم رسید:
public class PluralsightCourse
{
public bool UserIsAuthorizedForCourseTranscripts { get; set; }
public PluralsightCourseItems[] Modules { get; set; }
}
public class PluralsightCourseItems
{
public string Title { get; set; }
public PluralsightCourseClip[] Clips { get; set; }
}
public class PluralsightCourseClip
{
public string Title { get; set; }
public string PlayerParameters { get; set; }
public PluralsightCourseClipTranscript[] Transcripts { get; set; }
}
public class PluralsightCourseClipTranscript
{
public float DisplayTime { get; set; }
public string Text { get; set; }
}
و بعد از تشکیل این ساختار که توسط منوی edit و گزینهی paste special ویژوال استودیو تشکیل شدهاست:
بارگذاری آن توسط
کتابخانهی JSON.NET به صورت ذیل خواهد بود:
public static PluralsightCourse ProcessJsonFile(string jsonData)
{
return JsonConvert.DeserializeObject<PluralsightCourse>(jsonData);
}
و پس از آن اگر حلقهای را بر روی ماژولها و سپس آیتمهای هر ماژول تشکیل دهیم، میتوان فرمت آنرا به فرمت استاندارد srt که قابلیت پخش در اکثر برنامههای video player را دارد (مانند kmplayer)، تبدیل کرد.
کدهای کامل این برنامه را از اینجا میتوانید دریافت کنید: PluralsightJsonTranscripts.V1.0.7z