5 Commits

Author SHA1 Message Date
14c251f3e4 Построение докер-образов в gitea 2025-11-22 01:17:38 +08:00
317ebfdf5f Dockerfile 2025-11-22 01:17:19 +08:00
68bb6199b9 Синтаксис Makefile + возможность передать ARCH 2025-11-21 00:15:06 +08:00
d6b133a8e0 Версия 1.0.6
All checks were successful
release / release (push) Successful in 6m33s
2025-11-19 00:15:38 +08:00
c9486c54b2 Улучшен парсинг названий каналов (#7) 2025-11-18 23:49:28 +08:00
7 changed files with 149 additions and 62 deletions

View File

@@ -1,28 +0,0 @@
name: release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout
with:
fetch-depth: 0
- name: Setup go
uses: https://github.com/actions/setup-go@v4
with:
go-version: '>=1.23.6'
- name: Compile
run: make release
- name: Make release
id: use-go-action
uses: https://gitea.com/actions/release-action@main
with:
files: |-
bin/*.zip
api_key: '${{secrets.RELEASE_TOKEN}}'

View File

@@ -0,0 +1,65 @@
# https://docs.gitea.com/usage/actions/overview
# https://docs.github.com/ru/actions/reference/workflows-and-actions/contexts
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with: # https://github.com/actions/checkout
fetch-depth: 0
- name: Set up go
uses: actions/setup-go@v4
with: # https://github.com/actions/setup-go
go-version: '>=1.24.2'
- name: Build release files (amd64)
run: make release ARCH=amd64
- name: Build release files (arm64)
run: make release ARCH=arm64
- name: Create new release
id: use-go-action
uses: https://gitea.com/actions/gitea-release-action@main
with: # https://gitea.com/actions/gitea-release-action
server_url: https://git.axenov.dev
token: '${{secrets.RELEASE_TOKEN}}'
files: |-
bin/*.zip
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with: # https://github.com/docker/setup-buildx-action
build-args: "IPTVC_VERSION=${{ github.ref_name }}"
buildkitd-config-inline: |
# https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md
[ registry."docker.io" ]
mirrors = ["https://dockerhub.timeweb.cloud", "https://dh-mirror.gitverse.ru"]
http = true
insecure = true
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with: # https://github.com/docker/login-action
registry: git.axenov.dev
username: ${{ secrets.USERNAME }}
password: ${{ secrets.RELEASE_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v5
with: # https://github.com/docker/build-push-action
context: .
push: true
tags: |
git.axenov.dev/iptv/iptvc:${{ github.ref_name }}
git.axenov.dev/iptv/iptvc:latest

24
Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
FROM golang:1.25-alpine AS iptv-img-builder
ARG GOOS
ARG GOARCH
ARG IPTVC_VERSION
ENV CGO_ENABLED=0
ENV GOOS=${GOOS:-linux}
ENV GOARCH=${GOARCH:-amd64}
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build \
-trimpath \
-ldflags="-s -w -X main.version=${IPTVC_VERSION}" \
-o /app/iptvc \
.
FROM alpine:3.22.2 AS iptv-img-checker
LABEL org.opencontainers.image.authors="Anthony Axenov <anthonyaxenov@gmail.com>"
WORKDIR /app
RUN apk add --no-cache ca-certificates tzdata
RUN addgroup -S iptvc-user && adduser -S -G iptvc-user -H -s /sbin/nologin iptvc-user
COPY --from=iptv-img-builder --chown=iptvc-user:iptvc-user /app/iptvc /app/iptvc
USER iptvc-user
ENTRYPOINT ["/app/iptvc"]

View File

@@ -1,46 +1,46 @@
.DEFAULT_GOAL=help
BINARY_NAME=iptvc
ARCH=amd64
BINARY_NAME := iptvc
ARCH ?= amd64
LINUX_PATH="bin/linux_${ARCH}"
WINDOWS_PATH="bin/windows_${ARCH}"
DARWIN_PATH="bin/darwin_${ARCH}"
LINUX_PATH := "bin/linux_$(ARCH)"
WINDOWS_PATH := "bin/windows_$(ARCH)"
DARWIN_PATH := "bin/darwin_$(ARCH)"
LINUX_FILE="${LINUX_PATH}/${BINARY_NAME}"
WINDOWS_FILE="${WINDOWS_PATH}/${BINARY_NAME}.exe"
DARWIN_FILE="${DARWIN_PATH}/${BINARY_NAME}"
LINUX_FILE := "$(LINUX_PATH)/$(BINARY_NAME)"
WINDOWS_FILE := "$(WINDOWS_PATH)/$(BINARY_NAME).exe"
DARWIN_FILE := "$(DARWIN_PATH)/$(BINARY_NAME)"
## clean: Remove all compiled binaries
clean:
@go clean
@rm -rf bin/
## linux: Build new binaries for linux (x64)
## linux: Build new binaries for linux
linux:
@rm -rf ${LINUX_PATH}
@GOARCH=${ARCH} GOOS=linux go build -o ${LINUX_FILE} . && echo "Compiled: ${LINUX_FILE}"
@rm -rf $(LINUX_PATH)
@GOARCH=$(ARCH) GOOS=linux go build -o $(LINUX_FILE) . && echo "Compiled: $(LINUX_FILE)"
## win: Build new binaries for windows (x64)
## win: Build new binaries for windows
win:
@rm -rf ${WINDOWS_PATH}
@GOARCH=${ARCH} GOOS=windows go build -o ${WINDOWS_FILE} . && echo "Compiled: ${WINDOWS_FILE}"
@rm -rf $(WINDOWS_PATH)
@GOARCH=$(ARCH) GOOS=windows go build -o $(WINDOWS_FILE) . && echo "Compiled: $(WINDOWS_FILE)"
## darwin: Build new binaries for darwin (x64)
## darwin: Build new binaries for darwin
darwin:
@rm -rf ${DARWIN_PATH}
@GOARCH=${ARCH} GOOS=darwin go build -o ${DARWIN_FILE} . && echo "Compiled: ${DARWIN_FILE}"
@rm -rf $(DARWIN_PATH)
@GOARCH=$(ARCH) GOOS=darwin go build -o $(DARWIN_FILE) . && echo "Compiled: $(DARWIN_FILE)"
## all: Build new binaries for linux, windows and darwin (x64)
## all: Build new binaries for linux, windows and darwin
all: clean linux win darwin
## release: Build all binaries and zip them
release: clean darwin linux win
@zip -j ${LINUX_PATH}.zip ${LINUX_FILE}
@zip -j ${DARWIN_PATH}.zip ${DARWIN_FILE}
@zip -j ${WINDOWS_PATH}.zip ${WINDOWS_FILE}
release: linux win darwin
@zip -j $(LINUX_PATH).zip $(LINUX_FILE)
@zip -j $(DARWIN_PATH).zip $(DARWIN_FILE)
@zip -j $(WINDOWS_PATH).zip $(WINDOWS_FILE)
## help: Show this message and exit
help: Makefile
@echo "Choose a command run:"
@echo "Available recipes:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'

View File

@@ -14,7 +14,7 @@ import (
"github.com/redis/go-redis/v9"
)
const VERSION = "1.0.5"
const VERSION = "1.0.6"
// Arguments описывает аргументы командной строки
type Arguments struct {

View File

@@ -106,17 +106,28 @@ func parseAttributes(line string) map[string]string {
return result
}
// parseName парсит название канала из строки тега #EXTINF
func parseName(line string) string {
//TODO https://git.axenov.dev/IPTV/iptvc/issues/7
parts := strings.Split(line, ",")
if len(parts) == 2 {
return strings.Trim(parts[1], " ")
}
// parseTitle парсит название канала из строки тега #EXTINF
func parseTitle(line string) string {
// сначала пытаемся по-доброму: в строке есть тег, могут быть атрибуты,
// есть запятая-разделитель, после неё -- название канала (с запятыми или без)
regex := regexp.MustCompile(`['"]?\s*,\s*(.+)`)
regexMatches := regex.FindAllStringSubmatch(line, -1)
return regexMatches[0][1]
if len(regexMatches) > 0 && len(regexMatches[0]) >= 2 {
return strings.TrimSpace(regexMatches[0][1])
}
// теперь пытаемся хоть как-то: в строке есть тег, могут быть атрибуты,
// НЕТ запятой-разделителя и название канала (с запятыми или без)
lastQuotePos := strings.LastIndexAny(line, `,"'`)
if lastQuotePos != -1 && lastQuotePos < len(line)-1 {
afterLastQuote := line[lastQuotePos+1:]
name := strings.TrimSpace(afterLastQuote)
if name != "" {
return name
}
}
return line // ну штош
}
// Download загружает плейлист по URL-адресу
@@ -170,7 +181,7 @@ func (pls *Playlist) Parse() Playlist {
if strings.HasPrefix(line, "#EXTINF") {
isChannel = true
tmpChannel.Attributes = parseAttributes(line)
tmpChannel.Title = parseName(line)
tmpChannel.Title = parseTitle(line)
if tmpChannel.Title == "" {
if tvgid, ok := tmpChannel.Attributes["tvg-id"]; ok {

15
build-docker-image.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
[[ "$1" ]] && DOCKER_TAG="$1" || DOCKER_TAG="latest"
[[ "$1" ]] && GIT_TAG="$1" || GIT_TAG=$(git describe --tags --always)
GIT_HASH=$(git rev-parse --short HEAD)
IPTVC_VERSION="${GIT_TAG}-${GIT_HASH}"
git checkout "${GIT_TAG}" 2>/dev/null
docker build \
--build-arg IPTVC_VERSION="${IPTVC_VERSION}" \
--tag iptvc:"${DOCKER_TAG}" \
--tag git.axenov.dev/iptv/iptvc:"${DOCKER_TAG}" \
.
docker push git.axenov.dev/iptv/iptvc:"${DOCKER_TAG}"