Ajax-Script

Advanced Renamer forum
#1 : 14/05-16 16:57
Mark
Mark
Posts: 1
Hi,
I would like to use AdvancedRenamer to modify my media library folder structure.
Let's say I want to add the year of a movie to the folder name, e.g.

Old folder name: Batman Begins
Desired new folder name: Batman Begins (2005)

Therefore I tried to write a script that uses the OMDB API. Here is my script
---------------------
var movie = item.name
// Make an AJAX call to the Open Movie Database, to grab this movie's details.
$.get("http://www.omdbapi.com/?t=' " + movie + " '&type=movie")
return item.newBasename + " (" + movie_data.Year + ")"
---------------------

However, the script doesn't work yet. First it says $ is not a valid command, and secondly I have not really an idea how to refer to the year-info of the request.
The OMDB returns the following object on the call:
{"Title":"Batman Begins","Year":"2005","Rated":"PG-13", ... ,"Response":"True"}


Can anyone help out? I know other programming languages but am not familiar with JS-syntax :P

EDIT:
I also tried adding a "library-loading" to the pre-batch script:

var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1 .4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();


14/05-16 16:57 - edited 15/05-16 11:33
#2 : 15/05-16 12:10
Kim Jensen
Kim Jensen
Administrator
Posts: 883
Reply to #1:
Advanced Renamer supports javascript though the Script method. This means you can write scripts is regular javascript to manipulate the values of the filenames. Advanced Renamer is not a web browser. The objects you use when writing scripts in a browser is not available here. Javascript is a language and a runtime engine. Ajax is not part of javascript. It is part of the features you can access in a browser though javascript. It is looks like you are using jQuery by using $.get. JQuery is a standalone library not part of the browser and not part of Advanced Renamer. You cannot access external script files from Advanced Renamer. Also you cannot do any DOM manipulation as there is no DOM.


15/05-16 12:10 - edited 15/05-16 12:14
#3 : 11/06-16 05:52
G. Lambany
G. Lambany
Posts: 187
since you know programming, you could start with this python script and modify it to add imdb/omdb query to it:

http://pastebin.com/mTwwQxtP

it uses exiftool for metadata tags, just like AR, if you need something from the movie files (or even write to them since exiftool can also write, but the script doesn't do that yet).

IMDbPY or omdb (a omdb api wrapper) are the two libraries needed for this

send me a mail if you need some help with the script, should be pretty easy to modify, but I could do it for you, if a standalone script is what you are looking for

[email protected]

cheers!


11/06-16 05:52 - edited 17/06-16 19:33