mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
Final work to add torrents categories
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -41,3 +41,5 @@ server/config.db
|
|||||||
server/web/pages/template/route.go
|
server/web/pages/template/route.go
|
||||||
server/server.pem
|
server/server.pem
|
||||||
server/server.key
|
server/server.key
|
||||||
|
settings.json
|
||||||
|
viewed.json
|
||||||
@@ -114,7 +114,7 @@ func GetTorrent(hashHex string) *Torrent {
|
|||||||
return tor
|
return tor
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetTorrent(hashHex, title, poster, data string) *Torrent {
|
func SetTorrent(hashHex, title, poster, category string, data string) *Torrent {
|
||||||
hash := metainfo.NewHashFromHex(hashHex)
|
hash := metainfo.NewHashFromHex(hashHex)
|
||||||
torr := bts.GetTorrent(hash)
|
torr := bts.GetTorrent(hash)
|
||||||
torrDb := GetTorrentDB(hash)
|
torrDb := GetTorrentDB(hash)
|
||||||
@@ -133,12 +133,14 @@ func SetTorrent(hashHex, title, poster, data string) *Torrent {
|
|||||||
}
|
}
|
||||||
torr.Title = title
|
torr.Title = title
|
||||||
torr.Poster = poster
|
torr.Poster = poster
|
||||||
|
torr.Category = category
|
||||||
torr.Data = data
|
torr.Data = data
|
||||||
}
|
}
|
||||||
|
|
||||||
if torrDb != nil {
|
if torrDb != nil {
|
||||||
torrDb.Title = title
|
torrDb.Title = title
|
||||||
torrDb.Poster = poster
|
torrDb.Poster = poster
|
||||||
|
torrDb.Category = category
|
||||||
torrDb.Data = data
|
torrDb.Data = data
|
||||||
AddTorrentDB(torrDb)
|
AddTorrentDB(torrDb)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ func ListTorrentsDB() map[metainfo.Hash]*Torrent {
|
|||||||
torr.Poster = db.Poster
|
torr.Poster = db.Poster
|
||||||
torr.Timestamp = db.Timestamp
|
torr.Timestamp = db.Timestamp
|
||||||
torr.Size = db.Size
|
torr.Size = db.Size
|
||||||
|
torr.Category = db.Category
|
||||||
torr.Data = db.Data
|
torr.Data = db.Data
|
||||||
torr.Stat = state.TorrentInDB
|
torr.Stat = state.TorrentInDB
|
||||||
ret[torr.TorrentSpec.InfoHash] = torr
|
ret[torr.TorrentSpec.InfoHash] = torr
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ func setTorrent(req torrReqJS, c *gin.Context) {
|
|||||||
c.AbortWithError(http.StatusBadRequest, errors.New("hash is empty"))
|
c.AbortWithError(http.StatusBadRequest, errors.New("hash is empty"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
torr.SetTorrent(req.Hash, req.Title, req.Poster, req.Data)
|
torr.SetTorrent(req.Hash, req.Title, req.Poster, req.Category, req.Data)
|
||||||
c.Status(200)
|
c.Status(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,20 +118,20 @@ var Mstile150x150png []byte
|
|||||||
//go:embed pages/site.webmanifest
|
//go:embed pages/site.webmanifest
|
||||||
var Sitewebmanifest []byte
|
var Sitewebmanifest []byte
|
||||||
|
|
||||||
//go:embed pages/static/js/2.916c2545.chunk.js
|
//go:embed pages/static/js/2.00261e25.chunk.js
|
||||||
var Staticjs2916c2545chunkjs []byte
|
var Staticjs200261e25chunkjs []byte
|
||||||
|
|
||||||
//go:embed pages/static/js/2.916c2545.chunk.js.LICENSE.txt
|
//go:embed pages/static/js/2.00261e25.chunk.js.LICENSE.txt
|
||||||
var Staticjs2916c2545chunkjsLICENSEtxt []byte
|
var Staticjs200261e25chunkjsLICENSEtxt []byte
|
||||||
|
|
||||||
//go:embed pages/static/js/2.916c2545.chunk.js.map
|
//go:embed pages/static/js/2.00261e25.chunk.js.map
|
||||||
var Staticjs2916c2545chunkjsmap []byte
|
var Staticjs200261e25chunkjsmap []byte
|
||||||
|
|
||||||
//go:embed pages/static/js/main.55f380e1.chunk.js
|
//go:embed pages/static/js/main.4f4f0915.chunk.js
|
||||||
var Staticjsmain55f380e1chunkjs []byte
|
var Staticjsmain4f4f0915chunkjs []byte
|
||||||
|
|
||||||
//go:embed pages/static/js/main.55f380e1.chunk.js.map
|
//go:embed pages/static/js/main.4f4f0915.chunk.js.map
|
||||||
var Staticjsmain55f380e1chunkjsmap []byte
|
var Staticjsmain4f4f0915chunkjsmap []byte
|
||||||
|
|
||||||
//go:embed pages/static/js/runtime-main.f542387e.js
|
//go:embed pages/static/js/runtime-main.f542387e.js
|
||||||
var Staticjsruntimemainf542387ejs []byte
|
var Staticjsruntimemainf542387ejs []byte
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"files": {
|
"files": {
|
||||||
"main.js": "/static/js/main.55f380e1.chunk.js",
|
"main.js": "/static/js/main.4f4f0915.chunk.js",
|
||||||
"main.js.map": "/static/js/main.55f380e1.chunk.js.map",
|
"main.js.map": "/static/js/main.4f4f0915.chunk.js.map",
|
||||||
"runtime-main.js": "/static/js/runtime-main.f542387e.js",
|
"runtime-main.js": "/static/js/runtime-main.f542387e.js",
|
||||||
"runtime-main.js.map": "/static/js/runtime-main.f542387e.js.map",
|
"runtime-main.js.map": "/static/js/runtime-main.f542387e.js.map",
|
||||||
"static/js/2.916c2545.chunk.js": "/static/js/2.916c2545.chunk.js",
|
"static/js/2.00261e25.chunk.js": "/static/js/2.00261e25.chunk.js",
|
||||||
"static/js/2.916c2545.chunk.js.map": "/static/js/2.916c2545.chunk.js.map",
|
"static/js/2.00261e25.chunk.js.map": "/static/js/2.00261e25.chunk.js.map",
|
||||||
"index.html": "/index.html",
|
"index.html": "/index.html",
|
||||||
"static/js/2.916c2545.chunk.js.LICENSE.txt": "/static/js/2.916c2545.chunk.js.LICENSE.txt"
|
"static/js/2.00261e25.chunk.js.LICENSE.txt": "/static/js/2.00261e25.chunk.js.LICENSE.txt"
|
||||||
},
|
},
|
||||||
"entrypoints": [
|
"entrypoints": [
|
||||||
"static/js/runtime-main.f542387e.js",
|
"static/js/runtime-main.f542387e.js",
|
||||||
"static/js/2.916c2545.chunk.js",
|
"static/js/2.00261e25.chunk.js",
|
||||||
"static/js/main.55f380e1.chunk.js"
|
"static/js/main.4f4f0915.chunk.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -207,7 +207,7 @@ func RouteWebPages(route gin.IRouter) {
|
|||||||
etag := fmt.Sprintf("%x", md5.Sum(Browserconfigxml))
|
etag := fmt.Sprintf("%x", md5.Sum(Browserconfigxml))
|
||||||
c.Header("Cache-Control", "public, max-age=31536000")
|
c.Header("Cache-Control", "public, max-age=31536000")
|
||||||
c.Header("ETag", etag)
|
c.Header("ETag", etag)
|
||||||
c.Data(200, "application/xml; charset=utf-8", Browserconfigxml)
|
c.Data(200, "text/xml; charset=utf-8", Browserconfigxml)
|
||||||
})
|
})
|
||||||
|
|
||||||
route.GET("/dlnaicon-120.png", func(c *gin.Context) {
|
route.GET("/dlnaicon-120.png", func(c *gin.Context) {
|
||||||
@@ -280,46 +280,46 @@ func RouteWebPages(route gin.IRouter) {
|
|||||||
c.Data(200, "application/manifest+json", Sitewebmanifest)
|
c.Data(200, "application/manifest+json", Sitewebmanifest)
|
||||||
})
|
})
|
||||||
|
|
||||||
route.GET("/static/js/2.916c2545.chunk.js", func(c *gin.Context) {
|
route.GET("/static/js/2.00261e25.chunk.js", func(c *gin.Context) {
|
||||||
etag := fmt.Sprintf("%x", md5.Sum(Staticjs2916c2545chunkjs))
|
etag := fmt.Sprintf("%x", md5.Sum(Staticjs200261e25chunkjs))
|
||||||
c.Header("Cache-Control", "public, max-age=31536000")
|
c.Header("Cache-Control", "public, max-age=31536000")
|
||||||
c.Header("ETag", etag)
|
c.Header("ETag", etag)
|
||||||
c.Data(200, "application/javascript; charset=utf-8", Staticjs2916c2545chunkjs)
|
c.Data(200, "text/javascript; charset=utf-8", Staticjs200261e25chunkjs)
|
||||||
})
|
})
|
||||||
|
|
||||||
route.GET("/static/js/2.916c2545.chunk.js.LICENSE.txt", func(c *gin.Context) {
|
route.GET("/static/js/2.00261e25.chunk.js.LICENSE.txt", func(c *gin.Context) {
|
||||||
etag := fmt.Sprintf("%x", md5.Sum(Staticjs2916c2545chunkjsLICENSEtxt))
|
etag := fmt.Sprintf("%x", md5.Sum(Staticjs200261e25chunkjsLICENSEtxt))
|
||||||
c.Header("Cache-Control", "public, max-age=31536000")
|
c.Header("Cache-Control", "public, max-age=31536000")
|
||||||
c.Header("ETag", etag)
|
c.Header("ETag", etag)
|
||||||
c.Data(200, "text/plain; charset=utf-8", Staticjs2916c2545chunkjsLICENSEtxt)
|
c.Data(200, "text/plain; charset=utf-8", Staticjs200261e25chunkjsLICENSEtxt)
|
||||||
})
|
})
|
||||||
|
|
||||||
route.GET("/static/js/2.916c2545.chunk.js.map", func(c *gin.Context) {
|
route.GET("/static/js/2.00261e25.chunk.js.map", func(c *gin.Context) {
|
||||||
etag := fmt.Sprintf("%x", md5.Sum(Staticjs2916c2545chunkjsmap))
|
etag := fmt.Sprintf("%x", md5.Sum(Staticjs200261e25chunkjsmap))
|
||||||
c.Header("Cache-Control", "public, max-age=31536000")
|
c.Header("Cache-Control", "public, max-age=31536000")
|
||||||
c.Header("ETag", etag)
|
c.Header("ETag", etag)
|
||||||
c.Data(200, "application/json", Staticjs2916c2545chunkjsmap)
|
c.Data(200, "application/json", Staticjs200261e25chunkjsmap)
|
||||||
})
|
})
|
||||||
|
|
||||||
route.GET("/static/js/main.55f380e1.chunk.js", func(c *gin.Context) {
|
route.GET("/static/js/main.4f4f0915.chunk.js", func(c *gin.Context) {
|
||||||
etag := fmt.Sprintf("%x", md5.Sum(Staticjsmain55f380e1chunkjs))
|
etag := fmt.Sprintf("%x", md5.Sum(Staticjsmain4f4f0915chunkjs))
|
||||||
c.Header("Cache-Control", "public, max-age=31536000")
|
c.Header("Cache-Control", "public, max-age=31536000")
|
||||||
c.Header("ETag", etag)
|
c.Header("ETag", etag)
|
||||||
c.Data(200, "application/javascript; charset=utf-8", Staticjsmain55f380e1chunkjs)
|
c.Data(200, "text/javascript; charset=utf-8", Staticjsmain4f4f0915chunkjs)
|
||||||
})
|
})
|
||||||
|
|
||||||
route.GET("/static/js/main.55f380e1.chunk.js.map", func(c *gin.Context) {
|
route.GET("/static/js/main.4f4f0915.chunk.js.map", func(c *gin.Context) {
|
||||||
etag := fmt.Sprintf("%x", md5.Sum(Staticjsmain55f380e1chunkjsmap))
|
etag := fmt.Sprintf("%x", md5.Sum(Staticjsmain4f4f0915chunkjsmap))
|
||||||
c.Header("Cache-Control", "public, max-age=31536000")
|
c.Header("Cache-Control", "public, max-age=31536000")
|
||||||
c.Header("ETag", etag)
|
c.Header("ETag", etag)
|
||||||
c.Data(200, "application/json", Staticjsmain55f380e1chunkjsmap)
|
c.Data(200, "application/json", Staticjsmain4f4f0915chunkjsmap)
|
||||||
})
|
})
|
||||||
|
|
||||||
route.GET("/static/js/runtime-main.f542387e.js", func(c *gin.Context) {
|
route.GET("/static/js/runtime-main.f542387e.js", func(c *gin.Context) {
|
||||||
etag := fmt.Sprintf("%x", md5.Sum(Staticjsruntimemainf542387ejs))
|
etag := fmt.Sprintf("%x", md5.Sum(Staticjsruntimemainf542387ejs))
|
||||||
c.Header("Cache-Control", "public, max-age=31536000")
|
c.Header("Cache-Control", "public, max-age=31536000")
|
||||||
c.Header("ETag", etag)
|
c.Header("ETag", etag)
|
||||||
c.Data(200, "application/javascript; charset=utf-8", Staticjsruntimemainf542387ejs)
|
c.Data(200, "text/javascript; charset=utf-8", Staticjsruntimemainf542387ejs)
|
||||||
})
|
})
|
||||||
|
|
||||||
route.GET("/static/js/runtime-main.f542387e.js.map", func(c *gin.Context) {
|
route.GET("/static/js/runtime-main.f542387e.js.map", func(c *gin.Context) {
|
||||||
|
|||||||
@@ -26,12 +26,13 @@ export default function AddDialog({
|
|||||||
title: originalTitle,
|
title: originalTitle,
|
||||||
name: originalName,
|
name: originalName,
|
||||||
poster: originalPoster,
|
poster: originalPoster,
|
||||||
|
category: originalCategory,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const isEditMode = !!originalHash
|
const isEditMode = !!originalHash
|
||||||
const [torrentSource, setTorrentSource] = useState(originalHash || '')
|
const [torrentSource, setTorrentSource] = useState(originalHash || '')
|
||||||
const [title, setTitle] = useState(originalTitle || '')
|
const [title, setTitle] = useState(originalTitle || '')
|
||||||
const [category, setCategory] = useState('Unknown')
|
const [category, setCategory] = useState(originalCategory || '')
|
||||||
const [originalTorrentTitle, setOriginalTorrentTitle] = useState('')
|
const [originalTorrentTitle, setOriginalTorrentTitle] = useState('')
|
||||||
const [parsedTitle, setParsedTitle] = useState('')
|
const [parsedTitle, setParsedTitle] = useState('')
|
||||||
const [posterUrl, setPosterUrl] = useState(originalPoster || '')
|
const [posterUrl, setPosterUrl] = useState(originalPoster || '')
|
||||||
@@ -248,7 +249,6 @@ export default function AddDialog({
|
|||||||
setTorrentSource={setTorrentSource}
|
setTorrentSource={setTorrentSource}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<RightSideComponent
|
<RightSideComponent
|
||||||
originalTorrentTitle={originalTorrentTitle}
|
originalTorrentTitle={originalTorrentTitle}
|
||||||
setTitle={setTitle}
|
setTitle={setTitle}
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ export default function RightSideComponent({
|
|||||||
setIsUserInteractedWithPoster(true)
|
setIsUserInteractedWithPoster(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const torrentCategories = ['Movies', 'Series', 'Music', 'Other', 'Unknown']
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RightSide>
|
<RightSide>
|
||||||
<RightSideContainer isHidden={!isTorrentSourceCorrect || (isHashAlreadyExists && !isEditMode)}>
|
<RightSideContainer isHidden={!isTorrentSourceCorrect || (isHashAlreadyExists && !isEditMode)}>
|
||||||
@@ -113,26 +115,6 @@ export default function RightSideComponent({
|
|||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormControl fullWidth>
|
|
||||||
<InputLabel id='torrent-category-select-label'>Torrent category</InputLabel>
|
|
||||||
<Select
|
|
||||||
labelId='torrent-category-select-label'
|
|
||||||
id='torrent-category-select'
|
|
||||||
value={category}
|
|
||||||
label='Torrent category'
|
|
||||||
margin='dense'
|
|
||||||
onChange={handleCategoryChange}
|
|
||||||
variant='outlined'
|
|
||||||
fullWidth
|
|
||||||
>
|
|
||||||
<MenuItem value='Films'>Films</MenuItem>
|
|
||||||
<MenuItem value='Series'>Series</MenuItem>
|
|
||||||
<MenuItem value='Music'>Music</MenuItem>
|
|
||||||
<MenuItem value='Other'>Other</MenuItem>
|
|
||||||
<MenuItem value='Unknown'>Unknown</MenuItem>
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<TextField
|
<TextField
|
||||||
@@ -156,6 +138,25 @@ export default function RightSideComponent({
|
|||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<FormControl fullWidth>
|
||||||
|
<InputLabel id='torrent-category-select-label'>Torrent category</InputLabel>
|
||||||
|
<Select
|
||||||
|
labelId='torrent-category-select-label'
|
||||||
|
id='torrent-category-select'
|
||||||
|
value={category}
|
||||||
|
label='Torrent category'
|
||||||
|
margin='dense'
|
||||||
|
onChange={handleCategoryChange}
|
||||||
|
variant='outlined'
|
||||||
|
fullWidth
|
||||||
|
defaultValue='Unknown'
|
||||||
|
>
|
||||||
|
{torrentCategories.map(category => (
|
||||||
|
<MenuItem value={category}>{category}</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
|
||||||
<PosterWrapper>
|
<PosterWrapper>
|
||||||
<Poster poster={+isPosterUrlCorrect}>
|
<Poster poster={+isPosterUrlCorrect}>
|
||||||
{isPosterUrlCorrect ? <img src={posterUrl} alt='poster' /> : <NoImageIcon />}
|
{isPosterUrlCorrect ? <img src={posterUrl} alt='poster' /> : <NoImageIcon />}
|
||||||
|
|||||||
@@ -185,7 +185,14 @@ const Torrent = ({ torrent }) => {
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
{isEditDialogOpen && (
|
{isEditDialogOpen && (
|
||||||
<AddDialog hash={hash} title={title} name={name} poster={poster} handleClose={handleCloseEditDialog} />
|
<AddDialog
|
||||||
|
hash={hash}
|
||||||
|
title={title}
|
||||||
|
name={name}
|
||||||
|
poster={poster}
|
||||||
|
handleClose={handleCloseEditDialog}
|
||||||
|
category={category}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user