chrisalderson / horriblesubs-api Goto Github PK
View Code? Open in Web Editor NEWAn HorribleSubs API wrapper to get data from horriblesubs.info
License: MIT License
An HorribleSubs API wrapper to get data from horriblesubs.info
License: MIT License
I'm getting this error while using the README code.
const HorribleSubsApi = require("horriblesubs-api");
// Create a new instance of the module.
const horriblesubs = new HorribleSubsApi({ baseUrl: "https://horriblesubs.info/" });
app.use(express.static("public"));
// https://expressjs.com/en/starter/basic-routing.html
app.get("/", (request, res) => {
horriblesubs
.getAllAnime()
.then(res => {
const [data] = res;
console.log(data);
// Get data including episodes from horriblesubs.
res.send(horriblesubs.getAnimeData(data));
})
.then(res => console.log(res))
.catch(err => console.error(err));
});
Hi,
Love the work you're doing, it seems I'm getting a CORS issue, i just wrapped my service around yours, you can see below:
Error:
Fetch API cannot load http://horriblesubs.info/shows/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
horrible-subs.service.ts:
import { Injectable } from '@angular/core';
import * as HorribleSubsAPI from 'horriblesubs-api';
@Injectable()
export class HorribleSubsService {
private horribleSubs: HorribleSubsAPI;
constructor() {
this.horribleSubs = new HorribleSubsAPI();
}
public getAll(): any {
return this.horribleSubs.getAllAnime().then(res => {
const [ data ] = res;
console.log(data);
// Get data including episodes from horriblesubs.
return this.horribleSubs.getAnimeData(data);
}).then(res => console.log(res))
.catch(err => console.error(err));
}
}
Home component:
import { Component, OnInit } from '@angular/core';
import { HorribleSubsService } from 'app/horrible-subs.service';
@component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
public content: {};
constructor(private horribleSubs: HorribleSubsService) { }
ngOnInit() {
this.content = this.horribleSubs.getAll();
}
}
Any good way to resolve this?
Thanks!
Hi, I really appreciate the work you do and it has helped me out in some of my personal projects! Hoowever, just last night getAnimeData() stopped working.
My Code:
this.horribleSubs.getAllAnime().then((HsRes) => {
return HsRes;
}).then((data) => {
return this.horribleSubs.getAnimeData(data);
}).then((data) => {
res.send(data);
})
.catch(err => console.error(err));
The Error thrown:
{ HTTPError: Response code 404 (Not Found)
at StdError (C:\Users\LOLCAT\Documents\animstream\animstream-backend\node_modules\got\index.js:410:3)
at C:\Users\LOLCAT\Documents\animstream\animstream-backend\node_modules\got\index.js:454:3
at stream.catch.then.e (C:\Users\LOLCAT\Documents\animstream\animstream-backend\node_modules\got\index.js:182:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
name: 'HTTPError',
host: 'horriblesubs.info',
hostname: 'horriblesubs.info',
method: 'GET',
path: '/undefined?',
protocol: 'https:',
url: 'https://horriblesubs.info/undefined',
statusCode: 404,
statusMessage: 'Not Found',
headers:
{ date: 'Sat, 30 Sep 2017 11:43:40 GMT',
'content-type': 'text/html; charset=UTF-8',
'transfer-encoding': 'chunked',
connection: 'close',
'set-cookie': [ '__cfduid=d65ea6297084293854bcaf026ece578e71506771820; expires=Sun, 30-Sep-18 11:43:40 GMT; path=/; domain=.horriblesubs.info; HttpOnly' ]
,
vary: 'Cookie',
expires: 'Wed, 11 Jan 1984 05:00:00 GMT',
'cache-control': 'no-cache, must-revalidate, max-age=0',
link: '<http://horriblesubs.info/wp-json/>; rel="https://api.w.org/"',
server: 'cloudflare-nginx',
'cf-ray': '3a66ed037dfe6b91-LHR',
'content-encoding': 'gzip' } }
I would assume changed their DOM in some way which could be the reason throwing this error?
Uncaught (in promise) ReferenceError: setImmediate is not defined
at requestAsEventEmitter (test.js:8932)
at PCancelable (test.js:8944)
at PCancelable._promise.Promise (test.js:9472)
at new Promise (<anonymous>)
at new PCancelable (test.js:9469)
at asPromise (test.js:8943)
at got (test.js:9195)
at Function.got.(anonymous function) [as get] (http://localhost:3002/assets/js/test.js:9213:31)
at HorribleSubsApi._get (test.js:8256)
at HorribleSubsApi.getAllAnime (test.js:8266)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.