Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var App = &cli.App{ Name: "ellu-dl", Usage: "Utility to convert Ellu reader to EPUB", ArgsUsage: "<url>", Flags: []cli.Flag{ &cli.StringFlag{Name: "cookie", EnvVars: []string{"ELLU_COOKIE"}, Usage: "\"sid\" cookie", Required: true}, &cli.BoolFlag{Name: "preview", Usage: "consume /reader-preview instead of /reader"}, }, Before: func(ctx *cli.Context) error { want := 1 if ctx.Args().Len() != want { return fmt.Errorf("expected %d args, got %d", want, ctx.Args().Len()) } return nil }, Action: func(ctx *cli.Context) error { pUrl, err := url.Parse(ctx.Args().Get(0)) if err != nil { return err } c := scrape.InitScraper(ctx.Context, &scrape.Scraper{ Cookies: []*network.CookieParam{{ Name: "sid", Value: ctx.String("cookie"), Domain: pUrl.Host, }}, Timeout: 30 * time.Second, }) book, err := getMetadata(c, pUrl) if err != nil { return fmt.Errorf("getting book id: %w", err) } root := pUrl.Scheme + "://" + pUrl.Host previewStr := "" if ctx.Bool("preview") { previewStr = "-preview" } rootURL := fmt.Sprintf("%s/reader%s?book_id=%d", root, previewStr, book.Id) if err = book.getChapters(c, rootURL); err != nil { return fmt.Errorf("getting book metadata: %w", err) } err = book.chaptersPopulate(c, rootURL) if err != nil { return fmt.Errorf("populating book chapters: %w", err) } e := epub.NewEpub(book.Title) e.SetIdentifier(strconv.Itoa(book.ISBN)) e.SetAuthor(book.Author) err = book.filesPopulate(c, root, e) if err != nil { return fmt.Errorf("populating EPUB files: %w", err) } for _, chapter := range book.Chapters { _, err := e.AddSection(chapter.Content, chapter.Title, "", "") if err != nil { return fmt.Errorf("adding chapter %d to epub: %w", chapter.Id, err) } } err = e.Write(fmt.Sprintf("%s (%d).epub", book.Title, book.Id)) return err }, }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.