Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 114 additions & 37 deletions build/buildmacos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,133 @@
set -e

# Variables
OUTPUT_DIR="../build" # Adjusted to place the binary in the build directory
BINARY_NAME="goanime-apple-darwin"
BINARY_PATH="$OUTPUT_DIR/$BINARY_NAME"
TARBALL_NAME="$BINARY_NAME.tar.gz"
TARBALL_PATH="$OUTPUT_DIR/$TARBALL_NAME"
CHECKSUM_FILE="$TARBALL_PATH.sha256"
OUTPUT_DIR="../build" # Adjusted to place the binaries in the build directory
BINARY_NAME_AMD64="goanime-darwin-amd64"
BINARY_NAME_ARM64="goanime-darwin-arm64"
BINARY_NAME_UNIVERSAL="goanime-darwin-universal"
BINARY_NAME_UNIVERSAL_GENERIC="goanime-darwin"
BINARY_PATH_AMD64="$OUTPUT_DIR/$BINARY_NAME_AMD64"
BINARY_PATH_ARM64="$OUTPUT_DIR/$BINARY_NAME_ARM64"
BINARY_PATH_UNIVERSAL="$OUTPUT_DIR/$BINARY_NAME_UNIVERSAL"
BINARY_PATH_UNIVERSAL_GENERIC="$OUTPUT_DIR/$BINARY_NAME_UNIVERSAL_GENERIC"
MAIN_PACKAGE="../cmd/goanime"

# Create the output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

echo "Building the goanime binary for macOS..."
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o "$BINARY_PATH" -ldflags="-s -w" -trimpath "$MAIN_PACKAGE"
echo "Building goanime binaries for macOS..."

echo "Build completed: $BINARY_PATH"
# Build for Intel (amd64)
echo "Building for Intel (amd64)..."
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o "$BINARY_PATH_AMD64" -ldflags="-s -w" -trimpath "$MAIN_PACKAGE"
echo "Intel build completed: $BINARY_PATH_AMD64"

# Check if UPX is installed
if command -v upx >/dev/null 2>&1; then
echo "Compressing the binary with UPX..."
if upx --best --ultra-brute --force-macos "$BINARY_PATH" 2>/dev/null; then
echo "Compression completed."
else
echo "UPX compression failed for macOS binary. Continuing without compression."
fi
# Build for Apple Silicon (arm64)
echo "Building for Apple Silicon (arm64)..."
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o "$BINARY_PATH_ARM64" -ldflags="-s -w" -trimpath "$MAIN_PACKAGE"
echo "Apple Silicon build completed: $BINARY_PATH_ARM64"

# Create universal binary using lipo
echo "Creating universal binary..."
if command -v lipo >/dev/null 2>&1; then
lipo -create -output "$BINARY_PATH_UNIVERSAL" "$BINARY_PATH_AMD64" "$BINARY_PATH_ARM64"
echo "Universal binary created: $BINARY_PATH_UNIVERSAL"

# Create a copy with generic name for updater compatibility
cp "$BINARY_PATH_UNIVERSAL" "$BINARY_PATH_UNIVERSAL_GENERIC"
echo "Generic universal binary created: $BINARY_PATH_UNIVERSAL_GENERIC"
else
echo "UPX not found. Skipping compression."
echo "Warning: lipo command not found. Cannot create universal binary."
fi

# Check if the binary was built successfully
if [ ! -f "$BINARY_PATH" ]; then
echo "Error: Binary not found at $BINARY_PATH. Build may have failed."
exit 1
# Function to compress binary with UPX
compress_binary() {
local binary_path="$1"
local binary_name=$(basename "$binary_path")

if command -v upx >/dev/null 2>&1; then
echo "Compressing $binary_name with UPX..."
if upx --best --ultra-brute --force-macos "$binary_path" 2>/dev/null; then
echo "Compression completed for $binary_name."
else
echo "UPX compression failed for $binary_name. Continuing without compression."
fi
else
echo "UPX not found. Skipping compression for $binary_name."
fi
}

# Compress binaries
compress_binary "$BINARY_PATH_AMD64"
compress_binary "$BINARY_PATH_ARM64"
if [ -f "$BINARY_PATH_UNIVERSAL" ]; then
compress_binary "$BINARY_PATH_UNIVERSAL"
fi
if [ -f "$BINARY_PATH_UNIVERSAL_GENERIC" ]; then
compress_binary "$BINARY_PATH_UNIVERSAL_GENERIC"
fi

# Check if binaries were built successfully
for binary in "$BINARY_PATH_AMD64" "$BINARY_PATH_ARM64"; do
if [ ! -f "$binary" ]; then
echo "Error: Binary not found at $binary. Build may have failed."
exit 1
fi
done

# Create tarball
echo "Creating tarball..."
tar -czf "$TARBALL_PATH" -C "$OUTPUT_DIR" "$BINARY_NAME"
echo "Tarball created: $TARBALL_PATH"
# Function to create tarball and checksum
create_tarball_and_checksum() {
local binary_path="$1"
local binary_name=$(basename "$binary_path")
local tarball_name="$binary_name.tar.gz"
local tarball_path="$OUTPUT_DIR/$tarball_name"
local checksum_file="$tarball_path.sha256"

# Create tarball
echo "Creating tarball for $binary_name..."
tar -czf "$tarball_path" -C "$OUTPUT_DIR" "$binary_name"
echo "Tarball created: $tarball_path"

# Generate SHA256 checksum for the tarball
echo "Generating SHA256 checksum for $tarball_name..."
if command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$tarball_path" > "$checksum_file"
elif command -v openssl >/dev/null 2>&1; then
openssl dgst -sha256 "$tarball_path" | awk '{print $2}' > "$checksum_file"
else
echo "Neither shasum nor openssl is available. Cannot generate checksum for $tarball_name."
return 1
fi
echo "Checksum generated: $checksum_file"
}

# Generate SHA256 checksum for the tarball
echo "Generating SHA256 checksum for the tarball..."
if command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$TARBALL_PATH" > "$CHECKSUM_FILE"
elif command -v openssl >/dev/null 2>&1; then
openssl dgst -sha256 "$TARBALL_PATH" | awk '{print $2}' > "$CHECKSUM_FILE"
else
echo "Neither shasum nor openssl is available. Cannot generate checksum."
exit 1
# Create tarballs and checksums for all binaries
create_tarball_and_checksum "$BINARY_PATH_AMD64"
create_tarball_and_checksum "$BINARY_PATH_ARM64"
if [ -f "$BINARY_PATH_UNIVERSAL" ]; then
create_tarball_and_checksum "$BINARY_PATH_UNIVERSAL"
fi
if [ -f "$BINARY_PATH_UNIVERSAL_GENERIC" ]; then
create_tarball_and_checksum "$BINARY_PATH_UNIVERSAL_GENERIC"
fi

echo "Build script completed successfully. Generated binaries:"
echo "- Intel (amd64): $BINARY_PATH_AMD64"
echo "- Apple Silicon (arm64): $BINARY_PATH_ARM64"
if [ -f "$BINARY_PATH_UNIVERSAL" ]; then
echo "- Universal (explicit): $BINARY_PATH_UNIVERSAL"
fi
if [ -f "$BINARY_PATH_UNIVERSAL_GENERIC" ]; then
echo "- Universal (generic): $BINARY_PATH_UNIVERSAL_GENERIC"
fi
echo "Checksum generated: $CHECKSUM_FILE"

echo "Build script completed successfully."
echo ""
echo "GitHub Release Assets:"
echo "- goanime-darwin-amd64 (Intel macOS)"
echo "- goanime-darwin-arm64 (Apple Silicon macOS)"
if [ -f "$BINARY_PATH_UNIVERSAL" ]; then
echo "- goanime-darwin-universal (Universal macOS - explicit)"
fi
if [ -f "$BINARY_PATH_UNIVERSAL_GENERIC" ]; then
echo "- goanime-darwin (Universal macOS - fallback for updater)"
fi
33 changes: 6 additions & 27 deletions docs/SCRAPING_INTEGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This integration adds powerful web scraping capabilities to GoAnime, inspired by the popular `ani-cli` script. It supports multiple anime streaming sources with automatic fallback and enhanced download features.

## 🌟 New Features
## New Features

### Multi-Source Support
- **AllAnime.day**: High-quality streams with multiple resolution options
Expand All @@ -22,7 +22,7 @@ This integration adds powerful web scraping capabilities to GoAnime, inspired by
- **720p, 1080p, 480p**: Specific resolution selection
- **hls**: HLS/m3u8 streams for better compatibility

## 🚀 Usage Examples
## Usage Examples

### Basic Usage
```bash
Expand Down Expand Up @@ -51,7 +51,7 @@ goanime -d --source animefire "naruto" 25
goanime -d --quality best "bleach" 100
```

## 🔧 Technical Implementation
## Technical Implementation

### Architecture Overview
```
Expand Down Expand Up @@ -84,21 +84,7 @@ type UnifiedScraper interface {
5. **Error Handling with Fallbacks**
6. **Metadata Extraction**

## 🔄 Migration from ani-cli

This integration brings many features from the popular `ani-cli` bash script:

### Supported ani-cli Features
- [x] Multi-source anime search
- [x] Quality selection (best, worst, specific resolutions)
- [x] Episode range downloads
- [x] HLS/m3u8 stream support
- [x] Subtitle extraction
- [x] Referrer handling for protected streams
- [x] User-agent spoofing
- [ ] Skip intro functionality (planned)
- [ ] Syncplay support (planned)
- [ ] VLC integration (planned)

### Command Equivalents
```bash
Expand All @@ -114,7 +100,7 @@ goanime -d -r "anime name" 1-5
goanime -d --quality 720p "anime name" 1
```

## 📋 Configuration
## Configuration

### Environment Variables
```bash
Expand Down Expand Up @@ -161,7 +147,7 @@ Enable verbose logging to troubleshoot issues:
goanime --debug -d --source allanime "your anime" 1
```

## 🔮 Future Enhancements
## Future Enhancements

### Planned Features
- [ ] Additional streaming sources
Expand All @@ -181,7 +167,7 @@ goanime --debug -d --source allanime "your anime" 1
- [ ] Web UI for remote control
- [ ] Mobile app companion

## 🤝 Contributing
## Contributing

To add a new anime source:

Expand All @@ -203,10 +189,3 @@ func (c *NewSourceClient) SearchAnime(query string, options ...interface{}) ([]*
}
```

## 📄 License

This enhanced scraping functionality is part of the GoAnime project and follows the same license terms. The implementation is inspired by `ani-cli` but written from scratch in Go.

---

**Note**: Always respect the terms of service of the streaming sites you're accessing. This tool is for educational purposes and personal use only.
38 changes: 19 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
module github.com/alvarorichard/Goanime

go 1.24.5
go 1.25

require (
github.com/Microsoft/go-winio v0.6.2
github.com/PuerkitoBio/goquery v1.10.3
github.com/alvarorichard/rich-go v0.0.0-20250531060310-d14b9a86fb85
github.com/charmbracelet/bubbles v0.21.0
github.com/charmbracelet/bubbletea v1.3.6
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.0
github.com/ktr0731/go-fuzzyfinder v0.9.0
github.com/manifoldco/promptui v0.9.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.10.0
golang.org/x/net v0.43.0
github.com/stretchr/testify v1.11.1
golang.org/x/net v0.46.0
)

require (
github.com/charmbracelet/huh v0.7.0
github.com/charmbracelet/log v0.4.2
github.com/lrstanley/go-ytdlp v1.2.2
github.com/lrstanley/go-ytdlp v1.2.6
)

require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/catppuccin/go v0.3.0 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20250820142022-371acb6ebad9 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20251013190359-01371c2be815 // indirect
github.com/clipperhouse/uax29/v2 v2.2.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logfmt/logfmt v0.6.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/ulikunitz/xz v0.5.13 // indirect
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect
github.com/ulikunitz/xz v0.5.15 // indirect
golang.org/x/exp v0.0.0-20251009144603-d2f985daa21b // indirect
)

require (
Expand All @@ -40,34 +41,33 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.3.2 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/x/ansi v0.10.1 // indirect; indirectn
github.com/charmbracelet/x/ansi v0.10.2 // indirect; indirectn
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/gdamore/encoding v1.0.1 // indirect
github.com/gdamore/tcell/v2 v2.8.1 // indirect
github.com/gdamore/tcell/v2 v2.9.0 // indirect
github.com/ktr0731/go-ansisgr v0.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/mattn/go-sqlite3 v1.14.32
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0
github.com/nsf/termbox-go v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/objx v0.5.3 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/term v0.34.0 // indirect
golang.org/x/text v0.28.0 // indirect
golang.org/x/crypto v0.43.0 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/term v0.36.0 // indirect
golang.org/x/text v0.30.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading
Loading