Skip to content

Commit

Permalink
#90 Fixed IMDb import not using the correct field name to extract Dat…
Browse files Browse the repository at this point in the history
…e Rated. This is used for both watched and rated dates when importing to trakt.tv. This is another recent changed by IMDb to throw people off!
  • Loading branch information
damienhaynes committed May 6, 2018
1 parent cdcda96 commit 9702347
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.3.0")]
[assembly: AssemblyFileVersion("2.3.3.0")]
[assembly: AssemblyVersion("2.3.4.0")]
[assembly: AssemblyFileVersion("2.3.4.0")]
2 changes: 1 addition & 1 deletion Sites/API/IMDb/IMDbFieldMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class IMDbFieldMapping
public const string cPosition = "Position";
public const string cIMDbID = "Const";
public const string cCreated = "Created";
public const string cAdded = "Date Added";
public const string cAdded = "Date Rated";
public const string cTitle = "Title";
public const string cType = "Title Type";
public const string cRating = "Your Rating";
Expand Down
11 changes: 5 additions & 6 deletions Sites/Common/IMDbHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ static string GetLastCreatedDate(Dictionary<string, string> item)
{
string createdDate = DateTime.UtcNow.ToString().ToISO8601();

// The 'created' field is used for watchlists and 'date added' for ratings
// The 'created' field is used for watchlists and 'date rated' for ratings
if (item.ContainsKey(IMDbFieldMapping.cCreated))
{
createdDate = GetLastCreatedDate(item[IMDbFieldMapping.cCreated]);
Expand All @@ -366,16 +366,15 @@ static string GetLastCreatedDate(Dictionary<string, string> item)

static string GetLastCreatedDate(string imdbDateTime)
{
DateTime result;
string createdDate = DateTime.Now.ToString().ToISO8601();

if (!string.IsNullOrEmpty(imdbDateTime))
{
// date is in the form 'YYYY-MM-DD'
string[] splits = imdbDateTime.Split(new[] { "-"}, StringSplitOptions.RemoveEmptyEntries);
if (splits.Count() == 3)
// date is in the form 'YYYY-MM-DD' (but no guarantee for other locales)
if (DateTime.TryParse(imdbDateTime, out result))
{
var localisedDate = new DateTime(Convert.ToInt16(splits[0]), Convert.ToInt16(splits[1]), Convert.ToInt16(splits[2]));
createdDate = localisedDate.ToString().ToISO8601();
createdDate = result.ToString().ToISO8601();
}
}

Expand Down

0 comments on commit 9702347

Please sign in to comment.