Skip to content

Commit ce2c04e

Browse files
authored
Merge pull request #14 from nandyalu/main
Add some updates
2 parents 4f59c7d + ec2afbe commit ce2c04e

File tree

6 files changed

+161
-5
lines changed

6 files changed

+161
-5
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Docker Publish for Release
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
tags:
8+
- 'v*'
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build_and_publish:
16+
name: Push Docker image to Github Container Registry
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
attestations: write
22+
id-token: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Install cosign
29+
if: github.event_name != 'pull_request'
30+
uses: sigstore/cosign-installer@v3.5.0
31+
with:
32+
cosign-release: 'v2.2.4'
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3.0.0
36+
37+
- name: Log into registry ${{ env.REGISTRY }}
38+
if: github.event_name != 'pull_request'
39+
uses: docker/login-action@v3.0.0
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GIT_TOKEN }}
44+
45+
- name: Ensure cache directory exists
46+
run: mkdir -p /tmp/.buildx-cache
47+
48+
- name: Cache Docker layers
49+
uses: actions/cache@v3
50+
with:
51+
# Cache key based on package.json and Dockerfile
52+
path: /tmp/.buildx-cache
53+
key: ${{ runner.os }}-docker-${{ hashFiles('package.json', 'Dockerfile') }}
54+
restore-keys: |
55+
${{ runner.os }}-docker-
56+
57+
- name: Extract Docker metadata
58+
id: meta
59+
uses: docker/metadata-action@v5
60+
with:
61+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
62+
tags: |
63+
type=ref,event=branch
64+
type=ref,event=pr
65+
type=semver,pattern={{version}}
66+
type=semver,pattern={{major}}.{{minor}}
67+
latest
68+
69+
- name: Build and push Docker image
70+
id: build-and-push
71+
uses: docker/build-push-action@v5
72+
with:
73+
context: .
74+
push: ${{ github.event_name != 'pull_request' }}
75+
tags: ${{ steps.meta.outputs.tags }}
76+
labels: ${{ steps.meta.outputs.labels }}
77+
cache-from: type=gha
78+
cache-to: type=gha,mode=max
79+
platforms: linux/amd64,linux/arm64
80+
build-args: |
81+
APP_VERSION=${{ github.ref_name }}
82+
83+
- name: Sign the published Docker image
84+
if: ${{ github.event_name != 'pull_request' }}
85+
env:
86+
TAGS: ${{ steps.meta.outputs.tags }}
87+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
88+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o main .
1818
FROM alpine:3.18
1919
RUN apk --no-cache add ca-certificates
2020

21+
# ARG APP_VERSION, will be set during build by github actions
22+
ARG APP_VERSION=0.0.0
23+
LABEL app.version=$APP_VERSION
24+
2125
# Set working directory in final image
2226
WORKDIR /app
2327

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ Settings are saved automatically to `/app/config/settings.json` inside the Docke
114114
1. **Configure Settings:** Set up your proxy and search providers (Prowlarr/Jackett) as described above.
115115
2. **Search:** Use the search bar to query Prowlarr or Jackett for torrents.
116116
3. **Add Torrent:** Paste a magnet link directly or click a search result to add the torrent to BitPlay.
117+
118+
> BitPlay also supports opening from another app/program by providing torrent or magnet link as query parameter `torrent`. The link needs to be URL-encoded!
119+
>
120+
> Ex: `http://localhost:3347?torrent=magnet%3A%3Fxt%3Durn%3Abtih%3A08ada5a7a6183aae1e09d831df6748d566095a10%26dn%3DSintel%26tr%3Dudp%253A%252F%252Fexplodie.org%253A6969%26tr%3Dudp%253A%252F%252Ftracker.coppersurfer.tk%253A6969%26tr%3Dudp%253A%252F%252Ftracker.empire-js.us%253A1337%26tr%3Dudp%253A%252F%252Ftracker.leechers-paradise.org%253A6969%26tr%3Dudp%253A%252F%252Ftracker.opentrackr.org%253A1337%26tr%3Dwss%253A%252F%252Ftracker.btorrent.xyz%26tr%3Dwss%253A%252F%252Ftracker.fastcast.nz%26tr%3Dwss%253A%252F%252Ftracker.openwebtorrent.com%26ws%3Dhttps%253A%252F%252Fwebtorrent.io%252Ftorrents%252F%26xs%3Dhttps%253A%252F%252Fwebtorrent.io%252Ftorrents%252Fsintel.torrent`
121+
117122
4. **Stream:** Once the torrent info is loaded, select the video file you want to watch. BitPlay will start downloading and streaming it directly in the built-in player.
118123

119124
## Contributing

client/assets/video-js.min.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/assets/video.min.js

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/index.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
content="BitPlay is a web-based torrent streaming application that allows you to stream torrents directly in your browser."
1010
/>
1111
<link rel="icon" href="assets/favicon.png" type="image/png" />
12-
<link
13-
href="https://vjs.zencdn.net/8.10.0/video-js.min.css"
14-
rel="stylesheet"
15-
/>
12+
<link rel="stylesheet" href="assets/video-js.min.css" />
1613
<link rel="stylesheet" href="assets/butterup.min.css" />
1714
<link rel="stylesheet" href="assets/output.css" />
1815
<script>
@@ -22,6 +19,18 @@
2219
} else {
2320
document.documentElement.classList.add("light");
2421
}
22+
// Read 'torrent' query parameter and set default value for magnet input
23+
document.addEventListener("DOMContentLoaded", function () {
24+
const urlParams = new URLSearchParams(window.location.search);
25+
const torrent = urlParams.get("torrent");
26+
if (torrent) {
27+
const decodedTorrent = decodeURIComponent(torrent);
28+
const magnetInput = document.getElementById("magnet");
29+
if (magnetInput) {
30+
magnetInput.value = decodedTorrent;
31+
}
32+
}
33+
});
2534
</script>
2635
</head>
2736

@@ -537,7 +546,7 @@ <h1 class="text-xl font-semibold">Settings</h1>
537546
</form>
538547
</div>
539548
</div>
540-
<script src="https://vjs.zencdn.net/8.10.0/video.min.js"></script>
549+
<script src="assets/video.min.js"></script>
541550
<script src="assets/videojs.hotkeys.min.js"></script>
542551
<script src="assets/butterup.min.js"></script>
543552
<script type="module" src="assets/index.js"></script>

0 commit comments

Comments
 (0)