Skip to content

Commit

Permalink
Fixed MAL search by name, Anichart broken due to their update
Browse files Browse the repository at this point in the history
  • Loading branch information
lodicolo committed Oct 14, 2014
1 parent 66fdb00 commit cb0e768
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions otaku-scraper/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ app.use(express.bodyParser());

apiRegister('/mal/search/:type', api.mal.search);

apiRegister('/mal/chart/anime/:start', api.mal.chart.anime)
apiRegister('/mal/chart/animePop/:start', api.mal.chart.animePop)
apiRegister('/mal/chart/manga/:start', api.mal.chart.manga)
apiRegister('/mal/chart/mangaPop/:start', api.mal.chart.mangaPop)
apiRegister('/mal/chart/anime/:start', api.mal.chart.anime)
apiRegister('/mal/chart/animePop/:start', api.mal.chart.animePop)
apiRegister('/mal/chart/manga/:start', api.mal.chart.manga)
apiRegister('/mal/chart/mangaPop/:start', api.mal.chart.mangaPop)

// MAL listings for users
apiRegister('/mal/list/fetch/:type/:user', api.mal.list.fetch);
Expand Down
4 changes: 3 additions & 1 deletion otaku-scraper/lib/api/anichart/anichart.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ var AniChart = (function() {
var returns = 0;
var callbacks = [];

console.log("chart length: " + chart.info.length);
for (var i = 0; i < chart.info.length; i++) {
callbacks[i] = (function(index) {
return function(err, mal_id) {
Expand Down Expand Up @@ -178,8 +179,9 @@ var AniChart = (function() {

chart.info = [];
var itrInfo = $(".anime_info,.anime_info_sml");
console.log("iterating");
console.log("iterating: " + itrInfo.length);
while (itrInfo.length > 0) {
console.log(itrInfo.length);
var contents = itrInfo.first().contents();
var tabinfo = contents.filter(".tabs").contents().filter(".tab_info").contents();
var info = {};
Expand Down
9 changes: 6 additions & 3 deletions otaku-scraper/lib/api/mal/anime.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ var Anime = (function() {

var that = this;

console.log("url: " + 'http://myanimelist.net/anime.php?' + params + '&q=' + encodeURIComponent(name.replace(/[\~\&\:\!\.\*]/g, "")).replace(/%2B/g, "+"));
request({
url: 'http://myanimelist.net/anime.php?' + params + '&q=' + encodeURIComponent(name.replace(/[\~\&\:\!\.\*]/g, "")),
url: 'http://myanimelist.net/anime.php?' + params + '&q=' + encodeURIComponent(name.replace(/[\~\&\:\!\.\*]/g, "")).replace(/%2B/g, "+"),
headers: {
'User-Agent': 'api-team-692e8861471e4de2fd84f6d91d1175c0'
},
Expand All @@ -200,11 +201,12 @@ var Anime = (function() {

if (isresults) {
if (body.indexOf("No titles that matched your query were found.") == -1) {
var atag = $("a:contains('" + name.toLowerCase() + "')");
var cleanName = decodeURIComponent(name.replace(/_/g, " ")).replace(/\+/g, " ");
var atag = $("a:contains('" + cleanName + "')");
atag.each(function(index, element) {
var selector = $(element);

if (selector.text().trim() == name.toLowerCase().trim()) {
if (selector.text().trim() == cleanName.toLowerCase().trim()) {
atag = selector;
}
});
Expand All @@ -221,6 +223,7 @@ var Anime = (function() {
mal_id = body.substring(idxDoEdit, body.indexOf(");", idxDoEdit));
}

console.log("the malid: " + mal_id);
mal_id = new Number(mal_id);
if (isNaN(mal_id))
mal_id = -2;
Expand Down

0 comments on commit cb0e768

Please sign in to comment.