Skip to content

Commit

Permalink
Merge pull request #12 from ahmedayman4a/release-2.0.0
Browse files Browse the repository at this point in the history
Release v2.0.0
  • Loading branch information
ahmedayman4a authored Mar 6, 2021
2 parents 882bf21 + cdf00d2 commit dbd2669
Show file tree
Hide file tree
Showing 67 changed files with 10,651 additions and 1,393 deletions.
22 changes: 0 additions & 22 deletions LyndaCoursesDownloader.CourseContent/AvailableVideos.cs

This file was deleted.

23 changes: 7 additions & 16 deletions LyndaCoursesDownloader.CourseContent/Chapter.cs
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; }
}
}
45 changes: 45 additions & 0 deletions LyndaCoursesDownloader.CourseContent/Converter.cs
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;
}
}
}
31 changes: 26 additions & 5 deletions LyndaCoursesDownloader.CourseContent/Course.cs
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;
}
}
}
9 changes: 0 additions & 9 deletions LyndaCoursesDownloader.CourseContent/CurrentStatus.cs

This file was deleted.

16 changes: 0 additions & 16 deletions LyndaCoursesDownloader.CourseContent/Enumerators.cs

This file was deleted.

8 changes: 0 additions & 8 deletions LyndaCoursesDownloader.CourseContent/ICourse.cs

This file was deleted.

15 changes: 0 additions & 15 deletions LyndaCoursesDownloader.CourseContent/IdFiller.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions LyndaCoursesDownloader.CourseContent/Quality.cs
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
}
}
12 changes: 12 additions & 0 deletions LyndaCoursesDownloader.CourseContent/Serialize.cs
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);
}
}
43 changes: 16 additions & 27 deletions LyndaCoursesDownloader.CourseContent/Video.cs
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; }
}

}
10 changes: 0 additions & 10 deletions LyndaCoursesDownloader.CourseElements/AboutPage.cs

This file was deleted.

29 changes: 0 additions & 29 deletions LyndaCoursesDownloader.CourseElements/CaptionsPage.cs

This file was deleted.

40 changes: 0 additions & 40 deletions LyndaCoursesDownloader.CourseElements/ChapterBlock.cs

This file was deleted.

19 changes: 0 additions & 19 deletions LyndaCoursesDownloader.CourseElements/CoursePage.cs

This file was deleted.

Loading

0 comments on commit dbd2669

Please sign in to comment.