-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from ahmedayman4a/release-2.0.0
Release v2.0.0
- Loading branch information
Showing
67 changed files
with
10,651 additions
and
1,393 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,14 @@ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
|
||
namespace LyndaCoursesDownloader.CourseContent | ||
{ | ||
public class Chapter : ICourse | ||
public class Chapter | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public IList<Video> Videos { get; set; } | ||
[JsonProperty("Title")] | ||
public string Title { get; set; } | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
var chapter = obj as Chapter; | ||
if (chapter == null) | ||
{ | ||
return false; | ||
} | ||
return this.Id == chapter.Id; | ||
} | ||
|
||
public override int GetHashCode() => 19 * 31 + this.Id; | ||
[JsonProperty("Videos")] | ||
public List<Video> Videos { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace LyndaCoursesDownloader.CourseContent | ||
{ | ||
internal static class Converter | ||
{ | ||
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings | ||
{ | ||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore, | ||
DateParseHandling = DateParseHandling.None, | ||
}; | ||
} | ||
|
||
internal class ParseStringConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type t) => t == typeof(int) || t == typeof(int?); | ||
|
||
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer) | ||
{ | ||
if (reader.TokenType == JsonToken.Null) return null; | ||
var value = serializer.Deserialize<string>(reader); | ||
int i; | ||
if (Int32.TryParse(value, out i)) | ||
{ | ||
return i; | ||
} | ||
throw new Exception("Cannot unmarshal type long"); | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer) | ||
{ | ||
if (untypedValue == null) | ||
{ | ||
serializer.Serialize(writer, null); | ||
return; | ||
} | ||
var value = (int)untypedValue; | ||
serializer.Serialize(writer, value.ToString()); | ||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,33 @@ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace LyndaCoursesDownloader.CourseContent | ||
{ | ||
public class Course : ICourse | ||
public class Course | ||
{ | ||
public int Id { get; set; } = 1; | ||
public string Name { get; set; } | ||
public IList<Chapter> Chapters { get; set; } | ||
[JsonProperty("Chapters")] | ||
public List<Chapter> Chapters { get; set; } | ||
|
||
[JsonProperty("ID")] | ||
public int Id { get; set; } | ||
|
||
[JsonProperty("Title")] | ||
public string Title { get; set; } | ||
|
||
public string ExerciseFilesDownloadUrl { get; set; } | ||
|
||
public static Course FromJson(string json) | ||
{ | ||
Course course = JsonConvert.DeserializeObject<Course>(json, Converter.Settings); | ||
course.Chapters.ForEach(chapter => | ||
chapter.Videos.ForEach(video => | ||
{ | ||
video.ApiUrl = String.Format("https://www.lynda.com/ajax/course/{0}/{1}/play", course.Id, video.Id); | ||
video.SubtitlesUrl = String.Format("https://www.lynda.com/ajax/player/transcript?courseId={0}&videoId={1}", course.Id, video.Id); | ||
}) | ||
); | ||
return course; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace LyndaCoursesDownloader.CourseContent | ||
{ | ||
public enum Quality | ||
{ | ||
High, | ||
Medium, | ||
Low | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace LyndaCoursesDownloader.CourseContent | ||
{ | ||
public static class Serialize | ||
{ | ||
public static string ToJson(this Course self) => JsonConvert.SerializeObject(self, Converter.Settings); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,23 @@ | ||
namespace LyndaCoursesDownloader.CourseContent | ||
using Newtonsoft.Json; | ||
|
||
namespace LyndaCoursesDownloader.CourseContent | ||
{ | ||
public class Video : ICourse | ||
public class Video | ||
{ | ||
|
||
[JsonProperty("ID")] | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public string VideoUrl { get; set; } | ||
public string VideoDownloadUrl { get; set; } | ||
public string CaptionText { get; set; } | ||
public Chapter Chapter { get; set; } | ||
|
||
public CurrentStatus CurrentVideoStatus { get; set; } = CurrentStatus.Ready; | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
var video = obj as Video; | ||
if (video == null) | ||
{ | ||
return false; | ||
} | ||
return this.Id == video.Id && this.Chapter.Equals(video.Chapter); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
int hash = 19; | ||
hash = hash * 31 + this.Id; | ||
hash = hash * 31 + this.Chapter.GetHashCode(); | ||
return hash; | ||
} | ||
|
||
[JsonProperty("Title")] | ||
public string Title { get; set; } | ||
|
||
public string ApiUrl { get; set; } | ||
|
||
public string DownloadUrl { get; set; } | ||
|
||
public string SubtitlesUrl { get; set; } | ||
|
||
public string Subtitles { get; set; } | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.