Movie: Check movie year against searched year #1340
Conversation
Regarding the relevancy note. |
@@ -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), |
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)?
@moollaza
Regrading the use of Two options:
|
@MrChrisW Nice--what about queries like "RoboCop (2014 film) rotten tomatoes"? It looks like |
Also would like some indentation in there. :) |
@jagtalon The main duckduckhack JS contains the |
@jagtalon That's a wonderful query "RoboCop (2014 film) rotten tomatoes" 😆 Thanks for the curve ball ⚽ Few options when comparing the query to the movie title.
Any other ideas? |
@MrChrisW Maybe check if there's |
@jagtalon Best I can think of is below. This will allow the query `RoboCop (2014) rotten tomatoes. if (query.match(/\(.+?\)/g)) { #match parenthesis
query = query.replace(/\(|\)/g, ''); #remove parenthesis
} However |
Ping @jagtalon |
@MrChrisW got it! 👍 |
Movie: Check movie year against searched year
Fixes #1339
Ping pong @jagtalon
Example:
Note: There may be a relevancy issue, example search for "Babe 2006" https://duckduckgo.com/?q=Babe+2006+rotten+tomatoesFixed