Movie: Check movie year against searched year #1340
Changes from 2 commits
e6b3dcd
ddca1de
1f810de
7778abb
6a324cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,20 @@ | |
source = $(script).attr("src"), | ||
query = source.match(/movie\/([^\/]+)/)[1]; | ||
|
||
//Check if the query contains a year | ||
var year = decodeURIComponent(query).match(/\d{4}/gm), | ||
singleResult = []; | ||
|
||
if(year) { | ||
$.each(api_result.movies, function(key, result) { | ||
//Check movie year and title against query | ||
if(result.year == year && decodeURIComponent(query).replace(/\d{4}/,'').trim() == result.title.toLowerCase()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if the year is part of the movie? It's largely an edge case but I know "Death Race 2000" and "2001: A Space Odyssey" would fall into that category. -- We might need to check if the result movie title has a year and compare it to what we detected in which case it's likely the year is part of the title and not specifying a release date There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Easy! I'll add a check. |
||
singleResult.push(result); | ||
} | ||
}); | ||
if(singleResult.length>0) {api_result.movies = singleResult;} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure, but you may be able to move the comparison logic into It's intended for tile views, but I think in this case it would force the displayed result to be whatever the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like these properties will change the order of the items. Not sure it will work for displaying a single exact match. I'll definitely play around with these properties and see what happens 😄 |
||
} | ||
|
||
Spice.add({ | ||
id: 'movie', | ||
name: 'Movies', | ||
|
@@ -38,7 +52,6 @@ | |
itemType: 'Movies' | ||
}, | ||
normalize: function(item) { | ||
|
||
// Modify the image from _tmb.jpg to _det.jpg | ||
var image = toDetail(item.posters.detailed); | ||
return { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to but
\b
around the capture? Otherwise it'll capture 4 digits as a substring. Should probably also check that the year is a valid, ie. > 1900 and maybe < current year + 5 (to look for upcoming movies)?