Skip to content

Commit

Permalink
feat: add tmdb mapping support
Browse files Browse the repository at this point in the history
* feat: add tmdb map support

* feat: add ci
  • Loading branch information
varoOP authored Sep 20, 2023
1 parent c6cb4e0 commit d7cf18c
Show file tree
Hide file tree
Showing 12 changed files with 643 additions and 182 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: build

on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:

permissions:
contents: write

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

# 1.20 is the last version to support Windows < 10, Server < 2016, and MacOS < 1.15.
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.7"
cache: true

- name: Test
run: go test -v ./...

goreleaserbuild:
name: Build Go binaries
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

# 1.20 is the last version to support Windows < 10, Server < 2016, and MacOS < 1.15.
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.7"
cache: true

- name: Run GoReleaser build
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean --skip-validate --skip-publish --parallelism 99
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: shinkrodb
path: |
dist/*.tar.gz
dist/*.zip
goreleaser:
name: Build and publish binaries
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

# 1.20 is the last version to support Windows < 10, Server < 2016, and MacOS < 1.15.
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.7"
cache: true

- name: Run GoReleaser build and publish tags
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: shinkrodb
path: |
dist/*.tar.gz
dist/*.zip
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*secrets.json
*mal_cache
*mal_cache
*dist*
55 changes: 55 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
project_name: shinkrodb
before:
hooks:
- go mod tidy

builds:
- main: ./cmd/shinkrodb/
binary: shinkrodb
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm
- arm64
goarm:
- "6"
ignore:
- goos: freebsd
goarch: arm
- goos: freebsd
goarch: arm64

archives:
- name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"

checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
use: github
filters:
exclude:
- Merge pull request
- Merge remote-tracking branch
- Merge branch
groups:
- title: "New Features"
regexp: "^.*feat[(\\w)]*:+.*$"
order: 0
- title: "Bug fixes"
regexp: "^.*fix[(\\w)]*:+.*$"
order: 10
- title: Other work
order: 999

release:
prerelease: auto
footer: |
**Full Changelog**: https://github.com/varoOP/shinkrodb/compare/{{ .PreviousTag }}...{{ .Tag }}
31 changes: 25 additions & 6 deletions cmd/shinkrodb/main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
package main

import (
"fmt"
"path"

"github.com/spf13/pflag"
"github.com/varoOP/shinkrodb/internal/config"
"github.com/varoOP/shinkrodb/internal/domain"
)

func main() {
cfg := config.NewConfig()
//domain.GetMalIds(cfg)
//domain.ScrapeMal()
//domain.GetTvdbIDs()
domain.GetTmdbIds(cfg)
// a := domain.GetAnime("./malid-anidbid-tvdbid-tmdbid.json")
// fmt.Println("Total number of dupes:", domain.CheckDupes(a))
var rootPath string
pflag.StringVar(&rootPath, "rootPath", ".", "the path where output is saved")
pflag.Parse()

switch cmd := pflag.Arg(0); cmd {
case "run":
domain.GetMalIds(cfg)
domain.ScrapeMal()
domain.GetTvdbIDs()
domain.GetTmdbIds(cfg, rootPath)
a := domain.GetAnime("./malid-anidbid-tvdbid-tmdbid.json")
fmt.Println("Total number of dupes:", domain.CheckDupes(a))

case "genmap":
am := &domain.AnimeMovies{}
am.Get(path.Join(rootPath, "tmdb-mal-master.yaml"))
domain.CreateMapping(am, path.Join(rootPath, "tmdb-mal.yaml"))

default:
fmt.Println("ERROR: no command specified")
}
}
Loading

0 comments on commit d7cf18c

Please sign in to comment.