Skip to content

Commit

Permalink
Merge pull request #25 from AkshathSai/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AkshathSai authored Feb 6, 2024
2 parents 9b84a24 + fb720ec commit 7161168
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.akshathsaipittala.streamspace.dto.yts;

record YTSTorrent(
public record YTSTorrent(
String url,
String hash,
String quality,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@
import com.akshathsaipittala.streamspace.utils.TorrentUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;

import java.io.IOException;

// This class is used for
// Downloading torrents non-sequentially
// for faster download speed
@Lazy
@Slf4j
@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -73,14 +70,14 @@ public int getNumOfHashingThreads() {
return Runtime.getRuntime().availableProcessors();
}

@Override
/*@Override
public int getAcceptorPort() {
try {
return TorrentUtils.getRandomFreePort();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}*/
})
.autoLoadModules()
.module(dhtModule())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
import com.akshathsaipittala.streamspace.utils.TorrentUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;

@Lazy
@Slf4j
@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.akshathsaipittala.streamspace.utils.TorrentProgressHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.socket.WebSocketSession;
Expand All @@ -23,7 +22,6 @@
import java.io.IOException;
import java.text.DecimalFormat;

@Lazy
@Slf4j
@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@Slf4j
@Controller
@RequestMapping("/download")
@RequiredArgsConstructor
public class DownloadsController {

Expand All @@ -33,7 +31,7 @@ public String getDownloadQueue(Model model) {
}

@HxRequest
@PostMapping("/download/torrent")
@PostMapping("/torrent")
public HtmxResponse downloadTorrent(
@RequestParam("selectedOption") String torrentHash,
@RequestParam(value = "sequentialCheck", required = false) String sequentialCheck,
Expand Down Expand Up @@ -61,7 +59,7 @@ public HtmxResponse downloadTorrent(
}

@HxRequest
@PostMapping("/download/torrent/{torrentHash}")
@PostMapping("/torrent/{torrentHash}")
public HtmxResponse downloadTorrent(@PathVariable String torrentHash) {

log.info("Selected Option: {}", torrentHash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.ArrayList;

@Lazy
@Slf4j
@Service
public class YoutubeCrawlerService {
Expand Down
34 changes: 27 additions & 7 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -294,31 +294,51 @@
</div>
</div>

<div class="tab-pane fade" id="movies" role="tabpanel" aria-labelledby="movies-tab">
<div class="tab-pane fade" id="movies" role="tabpanel" aria-labelledby="movies-tab"
hx-boost="true"
hx-swap="transition:true">

<!--This is movies content-->

<div id="most-watched-movies" hx-get="/yts/ytsMostWatched" hx-trigger="click from:#movies-tab" hx-indicator=".globalProgress" hx-swap="innerHTML transition:true">
<div id="most-watched-movies"
hx-get="/yts/ytsMostWatched"
hx-trigger="click from:#movies-tab"
hx-indicator=".globalProgress">
<!--Loading most watched movies...-->
</div>

<div id="latest-movies" hx-get="/yts/ytsLatest" hx-trigger="click from:#movies-tab" hx-indicator=".globalProgress" hx-swap="innerHTML transition:true">
<div id="latest-movies"
hx-get="/yts/ytsLatest"
hx-trigger="click from:#movies-tab"
hx-indicator=".globalProgress">
<!--Loading Latest movies...-->
</div>

<div id="most-liked-movies" hx-get="/yts/ytsMostLiked" hx-trigger="click from:#movies-tab" hx-indicator=".globalProgress" hx-swap="innerHTML transition:true">
<div id="most-liked-movies"
hx-get="/yts/ytsMostLiked"
hx-trigger="click from:#movies-tab"
hx-indicator=".globalProgress">
<!--Loading Most Liked movies...-->
</div>

<div id="imdb-highest-rated-movies" hx-get="/yts/ytsImdbRating" hx-trigger="click from:#movies-tab" hx-indicator=".globalProgress" hx-swap="innerHTML transition:true">
<div id="imdb-highest-rated-movies"
hx-get="/yts/ytsImdbRating"
hx-trigger="click from:#movies-tab"
hx-indicator=".globalProgress">
<!--Loading IMDB Highest Rated movies...-->
</div>

<div id="latest-comedy-movies" hx-get="/yts/ytsLatestComedies" hx-trigger="click from:#movies-tab" hx-indicator=".globalProgress" hx-swap="innerHTML transition:true">
<div id="latest-comedy-movies"
hx-get="/yts/ytsLatestComedies"
hx-trigger="click from:#movies-tab"
hx-indicator=".globalProgress">
<!--Loading Latest Comedies...-->
</div>

<div id="must-watch-movies" hx-get="/yts/ytsMustWatch" hx-trigger="click from:#movies-tab" hx-indicator=".globalProgress" hx-swap="innerHTML transition:true">
<div id="must-watch-movies"
hx-get="/yts/ytsMustWatch"
hx-trigger="click from:#movies-tab"
hx-indicator=".globalProgress">
<!--Loading Must Watch movies...-->
</div>

Expand Down
96 changes: 72 additions & 24 deletions src/main/resources/templates/movies.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<div th:fragment="ytsMostWatched" th:remove="tag">

<div class="card-body d-flex align-items-center custom-icon">
<div class="card-body d-flex align-items-center">
<p class="card-title lead mb-0">Most Watched</p>
<a hx:get="@{/yts/movies/cat/{category}(category='mostwatched')}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
<a hx:get="@{/yts/movies/cat/{category}(category='mostwatched')}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<i class="bi bi-chevron-compact-right" style="cursor: pointer"></i>
</a>
</div>

<a th:each="movie: ${ytsMostWatchedRecord.data().movies()}"
hx:get="@{/yts/movies/{id}(id=${movie.id()})}" hx-boost="true" hx-target="#myTabContent" hx-swap="transition:true" hx-push-url="true">
hx:get="@{/yts/movies/{id}(id=${movie.id()})}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<img class="thumbnail img-thumbnail img-fluid"
th:src="${movie.large_cover_image()}"
th:src="@{${movie.large_cover_image()}}"
th:alt="${movie.title_long()}"
/>
</a>
Expand All @@ -19,17 +27,25 @@

<div th:fragment="ytsLatest" th:remove="tag">

<div class="card-body d-flex align-items-center custom-icon">
<div class="card-body d-flex align-items-center">
<p class="card-title lead mb-0">Latest Movies</p>
<a hx:get="@{/yts/movies/cat/{category}(category='latest')}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
<a hx:get="@{/yts/movies/cat/{category}(category='latest')}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<i class="bi bi-chevron-compact-right" style="cursor: pointer"></i>
</a>
</div>

<a th:each="movie: ${ytsLatestRecord.data().movies()}"
hx:get="@{/yts/movies/{id}(id=${movie.id()})}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
hx:get="@{/yts/movies/{id}(id=${movie.id()})}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<img class="thumbnail img-thumbnail img-fluid"
th:src="${movie.large_cover_image()}"
th:src="@{${movie.large_cover_image()}}"
th:alt="${movie.title_long()}"
/>
</a>
Expand All @@ -38,17 +54,25 @@

<div th:fragment="ytsMostLiked" th:remove="tag">

<div class="card-body d-flex align-items-center custom-icon">
<div class="card-body d-flex align-items-center">
<p class="card-title lead mb-0">Most Liked</p>
<a hx:get="@{/yts/movies/cat/{category}(category='mostliked')}" hx-boost="true" hx-target="#myTabContent" hx-swap="transition:true" hx-push-url="true">
<a hx:get="@{/yts/movies/cat/{category}(category='mostliked')}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<i class="bi bi-chevron-compact-right" style="cursor: pointer"></i>
</a>
</div>

<a th:each="movie: ${ytsMostLikedRecord.data().movies()}"
hx:get="@{/yts/movies/{id}(id=${movie.id()})}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
hx:get="@{/yts/movies/{id}(id=${movie.id()})}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<img class="thumbnail img-thumbnail img-fluid"
th:src="${movie.large_cover_image()}"
th:src="@{${movie.large_cover_image()}}"
th:alt="${movie.title_long()}"
/>
</a>
Expand All @@ -57,17 +81,25 @@

<div th:fragment="ytsImdbRating" th:remove="tag">

<div class="card-body d-flex align-items-center custom-icon">
<div class="card-body d-flex align-items-center">
<p class="card-title lead mb-0">IMDB Highest Rated</p>
<a hx:get="@{/yts/movies/cat/{category}(category='imdbrating')}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
<a hx:get="@{/yts/movies/cat/{category}(category='imdbrating')}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<i class="bi bi-chevron-compact-right" style="cursor: pointer"></i>
</a>
</div>

<a th:each="movie: ${ytsIMDBHighestRatedRecord.data().movies()}"
hx:get="@{/yts/movies/{id}(id=${movie.id()})}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
hx:get="@{/yts/movies/{id}(id=${movie.id()})}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<img class="thumbnail img-thumbnail img-fluid"
th:src="${movie.large_cover_image()}"
th:src="@{${movie.large_cover_image()}}"
th:alt="${movie.title_long()}"
/>
</a>
Expand All @@ -76,17 +108,25 @@

<div th:fragment="ytsLatestComedies" th:remove="tag">

<div class="card-body d-flex align-items-center custom-icon">
<div class="card-body d-flex align-items-center">
<p class="card-title lead mb-0">Latest Comedies</p>
<a hx:get="@{/yts/movies/cat/{category}(category='latestcomedies')}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
<a hx:get="@{/yts/movies/cat/{category}(category='latestcomedies')}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<i class="bi bi-chevron-compact-right" style="cursor: pointer"></i>
</a>
</div>

<a th:each="movie: ${ytsLatestComedyRecord.data().movies()}"
hx:get="@{/yts/movies/{id}(id=${movie.id()})}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
hx:get="@{/yts/movies/{id}(id=${movie.id()})}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<img class="thumbnail img-thumbnail img-fluid"
th:src="${movie.large_cover_image()}"
th:src="@{${movie.large_cover_image()}}"
th:alt="${movie.title_long()}"
/>
</a>
Expand All @@ -95,17 +135,25 @@

<div th:fragment="ytsMustWatch" th:remove="tag">

<div class="card-body d-flex align-items-center custom-icon">
<div class="card-body d-flex align-items-center">
<p class="card-title lead mb-0">Must Watch</p>
<a hx:get="@{/yts/movies/cat/{category}(category='mustwatch')}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
<a hx:get="@{/yts/movies/cat/{category}(category='mustwatch')}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<i class="bi bi-chevron-compact-right" style="cursor: pointer"></i>
</a>
</div>

<a th:each="movie: ${ytsMustWatchRecord.data().movies()}"
hx:get="@{/yts/movies/{id}(id=${movie.id()})}" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
hx:get="@{/yts/movies/{id}(id=${movie.id()})}"
hx-boost="true"
hx-target="#movies"
hx-swap="transition:true"
hx-push-url="true">
<img class="thumbnail img-thumbnail img-fluid"
th:src="${movie.large_cover_image()}"
th:src="@{${movie.large_cover_image()}}"
th:alt="${movie.title_long()}"
/>
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/viewAll.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1 class="mb-4" th:text="${category}"></h1>
<div class="col" th:each="movie: ${ytsMoviesRecord.data.movies}">
<div class="card h-100">
<a hx:get="@{/yts/movies/{id}(id=${movie.id()})}" hx-indicator=".globalProgress" hx-boost="true" hx-target="#movies" hx-swap="transition:true" hx-push-url="true">
<img th:src="${movie.large_cover_image}" th:alt="${movie.title_long}" class="card-img-top">
<img th:src="@{${movie.large_cover_image}}" th:alt="${movie.title_long}" class="card-img-top">
</a>
</div>
</div>
Expand Down
Loading

0 comments on commit 7161168

Please sign in to comment.