Initial commit

master
Stein Ivar Berghei 2022-06-30 10:20:29 +02:00
commit 8d0a42dc97
6 changed files with 352 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
mangasee
test.js

119
fakequery.js Normal file
View File

@ -0,0 +1,119 @@
// FakeQuery...
// So you can render things on the server and not have to rewrite all
// of your code to conditionally use jQuery.
// License: MIT
// var _ = require('underscore');
var document = []
var window = {
history: {},
location: {}
}
var app = {
directive: function() { return },
controller: function() { return }
}
var Cookies = {
get: function() { return },
set: function() { return }
}
var moment = function() { return { unix: function() { return }}}
// These methods return values... we'll return undefined.
var valueMethods = ["val", "attr", "width", "height"];
// These methods return strings... we'll return an empty string.
var stringMethods = ["html", "serialize"];
// Methods returning arrays... we'll return an empty array.
var arrayMethods = ["serializeArray", "toArray"];
// All of the functions contained on the $.fn prototype.
var chainMethods = [
"add", "addBack", "addClass", "after", "ajaxComplete",
"ajaxError", "ajaxSend", "ajaxStart", "ajaxStop", "ajaxSuccess",
"andSelf", "animate", "append", "appendTo", "before",
"bind", "blur", "change", "children", "clearQueue", "click",
"clone", "closest", "contents", "contextmenu",
"css", "data", "dblclick", "delay", "delegate", "dequeue",
"detach", "die", "domManip", "each", "empty", "end", "eq",
"error", "extend", "fadeIn", "fadeOut", "fadeTo", "fadeToggle",
"filter", "find", "first", "focus", "focusin", "focusout", "get",
"has", "hasClass", "hide", "hover", "index",
"innerHeight", "innerWidth", "insertAfter", "insertBefore", "is",
"keydown", "keypress", "keyup", "last", "lazyload", "live",
"load", "map", "mousedown", "mouseenter", "mouseleave",
"mousemove", "mouseout", "mouseover", "mouseup", "next",
"nextAll", "nextUntil", "not", "off", "offset", "offsetParent",
"on", "one", "outerHeight", "outerWidth", "parent", "parents",
"parentsUntil", "position", "prepend", "prependTo", "prev", "prevAll",
"prevUntil", "promise", "prop", "push", "pushStack", "queue", "ready",
"remove", "removeAttr", "removeClass", "removeData", "removeProp",
"replaceAll", "replaceWith", "resize", "scroll", "scrollLeft",
"scrollTop", "select", "show", "siblings", "size", "slice", "slideDown",
"slideToggle", "slideUp", "sort", "splice", "stop", "submit", "text",
"toArray", "toggle", "toggleClass", "trigger", "triggerHandler", "unbind", "undelegate",
"unload", "unwrap", "wrap", "wrapAll", "wrapInner"
];
var coreMethods = [
"Animation", "Callbacks", "Deferred", "Event", "Tween",
"_data", "_queueHooks", "abovethetop", "acceptData", "access", "ajax",
"ajaxPrefilter", "ajaxSetup", "ajaxTransport", "attr", "belowthefold",
"buildFragment", "camelCase", "clean", "cleanData", "clone", "contains",
"css", "data", "dequeue", "dir", "error", "extend", "filter",
"find", "fx", "get", "getJSON", "getScript", "globalEval", "grep",
"hasData", "holdReady", "inArray", "inviewport", "isArray", "isEmptyObject",
"isFunction", "isNumeric", "isPlainObject", "isWindow", "isXMLDoc", "leftofbegin",
"merge", "noConflict", "nodeName", "noop", "now", "param",
"parseHTML", "parseJSON", "parseXML", "post", "prop", "proxy", "queue", "ready",
"removeAttr", "removeData", "removeEvent", "rightoffold", "sibling", "speed",
"style", "sub", "swap", "text", "trim", "type", "uaMatch", "unique", "when"
];
var $ = function(selector, context) {
return new $.fn.init(selector, context);
};
$.fn = $.prototype = {
length: 0
};
_.each(valueMethods, function(item) {
$.fn[item] = function() { return void 0; };
});
_.each(stringMethods, function(item) {
$.fn[item] = function() { return ''; };
});
_.each(arrayMethods, function(item) {
$.fn[item] = function() { return []; };
});
_.each(chainMethods, function(item) {
$.fn[item] = function() { return $(this); };
});
$.fn.init = function(selector, context) {
// Handle $($);
if (selector instanceof $) return selector;
// Handle $(function() {});
if (typeof selector === 'function') {
return setTimeout(selector, 0);
}
// HANDLE: $(""), $(null), $(undefined), $(false), $("anything else")
return this;
};
$.fn.init.prototype = $.fn;
$.extend = function() { return _.extend.apply(_, arguments); };
$.each = function() { return _.each.apply(_, arguments); };
$.map = function() { return _.map.apply(_, arguments); };
$.makeArray = function() { return _.toArray.apply(_, arguments); };
jQuery = $

14
go.mod Normal file
View File

@ -0,0 +1,14 @@
module mangasee
go 1.16
require (
github.com/PuerkitoBio/goquery v1.6.1 // indirect
github.com/codegangsta/cli v1.20.0 // indirect
github.com/headzoo/surf v1.0.0 // indirect
github.com/mmcdole/gofeed v1.1.0 // indirect
github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac // indirect
gopkg.in/headzoo/surf.v1 v1.0.0 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
rogchap.com/v8go v0.5.1 // indirect
)

50
go.sum Normal file
View File

@ -0,0 +1,50 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/PuerkitoBio/goquery v1.6.1 h1:FgjbQZKl5HTmcn4sKBgvx8vv63nhyhIpv7lJpFGCWpk=
github.com/PuerkitoBio/goquery v1.6.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/andybalholm/cascadia v1.1.0 h1:BuuO6sSfQNFRu1LppgbD25Hr2vLYW25JvxHs5zzsLTo=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/codegangsta/cli v1.20.0/go.mod h1:/qJNoX69yVSKu5o4jLyXAENLRyk1uhi7zkbQ3slBdOA=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/headzoo/surf v1.0.0 h1:d2h9ftKeQYj7tKqAjQtAA0lJVkO8cTxvzdXLynmNnHM=
github.com/headzoo/surf v1.0.0/go.mod h1:/bct0m/iMNEqpn520y01yoaWxsAEigGFPnvyR1ewR5M=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/mmcdole/gofeed v1.1.0 h1:T2WrGLVJRV04PY2qwhEJLHCt9JiCtBhb6SmC8ZvJH08=
github.com/mmcdole/gofeed v1.1.0/go.mod h1:PPiVwgDXLlz2N83KB4TrIim2lyYM5Zn7ZWH9Pi4oHUk=
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf h1:sWGE2v+hO0Nd4yFU/S/mDBM5plIU8v/Qhfz41hkDIAI=
github.com/mmcdole/goxpp v0.0.0-20181012175147-0068e33feabf/go.mod h1:pasqhqstspkosTneA62Nc+2p9SOBBYAPbnmRRWPQ0V8=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac h1:kYPjbEN6YPYWWHI6ky1J813KzIq/8+Wg4TO4xU7A/KU=
github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/urfave/cli v1.22.3/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/headzoo/surf.v1 v1.0.0 h1:Ti4LagTvHxSdHYHf5DTqJRhY4+pQYZ0slBPlxo2IWGU=
gopkg.in/headzoo/surf.v1 v1.0.0/go.mod h1:T0BH8276y+OPL0E4tisxCFjBVIAKGbwdYU7AS7/EpQQ=
gopkg.in/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI=
gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
rogchap.com/v8go v0.5.1 h1:yx7uQC2ezAHthCHLHl4NuH3eprVLBtNl6Utm/ELjZ+w=
rogchap.com/v8go v0.5.1/go.mod h1:IitZnaOtWSJadY/7qinKHIEHpxsilMWyLQ+Efdo4n4I=

161
mangasee.go Normal file
View File

@ -0,0 +1,161 @@
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strconv"
"strings"
"github.com/PuerkitoBio/goquery"
"github.com/headzoo/surf"
"github.com/headzoo/surf/browser"
"github.com/mmcdole/gofeed/rss"
"rogchap.com/v8go"
)
type App struct {
vm *v8go.Isolate
browser *browser.Browser
fp rss.Parser
http *http.Client
js [][]byte
}
type MangaSeeChapter struct {
Chapter string
Type string
Page string
Date string
ChapterName string
Directory string
}
func ChapterImage(chstr string) string {
ch := chstr[1 : len(chstr)-1]
odd := chstr[len(chstr)-1:]
if odd == "0" {
return ch
} else {
return fmt.Sprintf("%s.%s", ch, odd)
}
}
func (app *App) GetFeed(uri string) (feed *rss.Feed, err error) {
resp, err := app.http.Get(uri)
if err != nil {
return
}
feed, err = app.fp.Parse(resp.Body)
if err != nil {
return
}
return
}
func (app *App) GetChapterImages(uri string) (err error) {
vm, err := v8go.NewContext(app.vm)
if err != nil {
return
}
err = app.browser.Open(uri)
if err != nil {
return
}
for _, f := range app.js {
_, err = vm.RunScript(string(f), "app.js")
if err != nil {
return
}
}
app.browser.Dom().Find("script").Each(func(_ int, s *goquery.Selection) {
if strings.Contains(s.Text(), "function MainFunction($http, $timeout){") {
_, err := vm.RunScript(s.Text(), "main.js")
if err != nil {
return
}
}
})
_, err = vm.RunScript("MainFunction()", "main.js")
if err != nil {
return
}
curpathname, err := vm.RunScript("CurPathName", "main.js")
if err != nil {
return
}
chidx, err := vm.RunScript("IndexName", "main.js")
if err != nil {
return
}
chjson, err := vm.RunScript("JSON.stringify(CurChapter)", "main.js")
if err != nil {
return
}
var ch MangaSeeChapter
err = json.Unmarshal([]byte(chjson.String()), &ch)
// src="https://{{vm.CurPathName}}/manga/To-You-The-Immortal/{{vm.CurChapter.Directory == '' ? '' : vm.CurChapter.Directory+'/'}}{{vm.ChapterImage(vm.CurChapter.Chapter)}}-{{vm.PageImage(Page)}}.png"
//fmt.Println(ch)
page, err := strconv.Atoi(ch.Page)
if err != nil {
return
}
for i := 1; i <= page; i++ {
fmt.Printf("(%s) https://%s/manga/%s/%s-%.3d.png\n", ch.Chapter, curpathname.String(), chidx.String(), ChapterImage(ch.Chapter), i)
}
return
}
func main() {
var err error
app := &App{}
underscore, err := ioutil.ReadFile("./underscore-min.js")
if err != nil {
panic(err)
}
fq, err := ioutil.ReadFile("./fakequery.js")
if err != nil {
panic(err)
}
app.js = append(app.js, underscore)
app.js = append(app.js, fq)
app.http = &http.Client{}
app.vm, err = v8go.NewIsolate()
if err != nil {
panic(err)
}
app.browser = surf.NewBrowser()
app.fp = rss.Parser{}
feed, err := app.GetFeed("https://mangasee123.com/rss/Rurouni-Kenshin-Hokkaido-Arc.xml")
if err != nil {
panic(err)
}
for _, item := range feed.Items {
app.GetChapterImages(item.Link)
}
}

6
underscore-min.js vendored Normal file

File diff suppressed because one or more lines are too long