You can now filter by resolution
If the display of stream resolution is enabled in the settings, the filtering now takes the resolution into account. So you can filter for "1080" and only get streams with a resolution of 1080p.
This commit is contained in:
parent
8aad31965d
commit
73159748cd
|
@ -11,6 +11,7 @@ public class Model {
|
||||||
private List<String> tags = new ArrayList<>();
|
private List<String> tags = new ArrayList<>();
|
||||||
private boolean online = false;
|
private boolean online = false;
|
||||||
private int streamUrlIndex = -1;
|
private int streamUrlIndex = -1;
|
||||||
|
private int streamResolution = -1;
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
|
@ -68,6 +69,14 @@ public class Model {
|
||||||
this.streamUrlIndex = streamUrlIndex;
|
this.streamUrlIndex = streamUrlIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStreamResolution() {
|
||||||
|
return streamResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreamResolution(int streamResolution) {
|
||||||
|
this.streamResolution = streamResolution;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
|
|
|
@ -45,6 +45,8 @@ import javafx.scene.control.ContextMenu;
|
||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.input.Clipboard;
|
||||||
|
import javafx.scene.input.ClipboardContent;
|
||||||
import javafx.scene.input.ContextMenuEvent;
|
import javafx.scene.input.ContextMenuEvent;
|
||||||
import javafx.scene.input.MouseButton;
|
import javafx.scene.input.MouseButton;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
|
@ -222,10 +224,12 @@ public class ThumbCell extends StackPane {
|
||||||
LOG.trace("Resolution queue size: {}", ThumbOverviewTab.queue.size());
|
LOG.trace("Resolution queue size: {}", ThumbOverviewTab.queue.size());
|
||||||
final int w = resolution[1];
|
final int w = resolution[1];
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
resolutionTag.setText(Integer.toString(w));
|
String _res = Integer.toString(w);
|
||||||
|
resolutionTag.setText(_res);
|
||||||
resolutionTag.setVisible(true);
|
resolutionTag.setVisible(true);
|
||||||
resolutionBackground.setVisible(true);
|
resolutionBackground.setVisible(true);
|
||||||
resolutionBackground.setWidth(resolutionTag.getBoundsInLocal().getWidth() + 4);
|
resolutionBackground.setWidth(resolutionTag.getBoundsInLocal().getWidth() + 4);
|
||||||
|
model.setStreamResolution(w);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (IOException | ParseException | PlaylistException | InterruptedException e) {
|
} catch (IOException | ParseException | PlaylistException | InterruptedException e) {
|
||||||
|
@ -236,8 +240,10 @@ public class ThumbCell extends StackPane {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ThumbOverviewTab.resolutionProcessing.remove(model);
|
ThumbOverviewTab.resolutionProcessing.remove(model);
|
||||||
|
String _res = Integer.toString(res[1]);
|
||||||
|
model.setStreamResolution(res[1]);
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
resolutionTag.setText(Integer.toString(res[1]));
|
resolutionTag.setText(_res);
|
||||||
resolutionTag.setVisible(true);
|
resolutionTag.setVisible(true);
|
||||||
resolutionBackground.setVisible(true);
|
resolutionBackground.setVisible(true);
|
||||||
resolutionBackground.setWidth(resolutionTag.getBoundsInLocal().getWidth() + 4);
|
resolutionBackground.setWidth(resolutionTag.getBoundsInLocal().getWidth() + 4);
|
||||||
|
@ -246,7 +252,7 @@ public class ThumbCell extends StackPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setImage(String url) {
|
private void setImage(String url) {
|
||||||
if(!Objects.equals(System.getenv("CTBREC_THUMBS"), "0")) {
|
if(!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||||
Image img = new Image(url, true);
|
Image img = new Image(url, true);
|
||||||
|
|
||||||
// wait for the image to load, otherwise the ImageView replaces the current image with an "empty" image,
|
// wait for the image to load, otherwise the ImageView replaces the current image with an "empty" image,
|
||||||
|
@ -277,12 +283,20 @@ public class ThumbCell extends StackPane {
|
||||||
MenuItem unfollow = new MenuItem("Unfollow");
|
MenuItem unfollow = new MenuItem("Unfollow");
|
||||||
unfollow.setOnAction((e) -> follow(false));
|
unfollow.setOnAction((e) -> follow(false));
|
||||||
|
|
||||||
|
MenuItem copyUrl = new MenuItem("Copy URL");
|
||||||
|
copyUrl.setOnAction((e) -> {
|
||||||
|
final Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||||
|
final ClipboardContent content = new ClipboardContent();
|
||||||
|
content.putString(model.getUrl());
|
||||||
|
clipboard.setContent(content);
|
||||||
|
});
|
||||||
|
|
||||||
ContextMenu contextMenu = new ContextMenu();
|
ContextMenu contextMenu = new ContextMenu();
|
||||||
contextMenu.setAutoHide(true);
|
contextMenu.setAutoHide(true);
|
||||||
contextMenu.setHideOnEscape(true);
|
contextMenu.setHideOnEscape(true);
|
||||||
contextMenu.setAutoFix(true);
|
contextMenu.setAutoFix(true);
|
||||||
MenuItem followOrUnFollow = parent instanceof FollowedTab ? unfollow : follow;
|
MenuItem followOrUnFollow = parent instanceof FollowedTab ? unfollow : follow;
|
||||||
contextMenu.getItems().addAll(openInPlayer, startStop , followOrUnFollow);
|
contextMenu.getItems().addAll(openInPlayer, startStop , followOrUnFollow, copyUrl);
|
||||||
return contextMenu;
|
return contextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,12 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
search.setPromptText("Filter");
|
search.setPromptText("Filter");
|
||||||
search.textProperty().addListener( (observableValue, oldValue, newValue) -> {
|
search.textProperty().addListener( (observableValue, oldValue, newValue) -> {
|
||||||
filter = search.getText();
|
filter = search.getText();
|
||||||
filter();
|
gridLock.lock();
|
||||||
|
try {
|
||||||
|
filter();
|
||||||
|
} finally {
|
||||||
|
gridLock.unlock();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
BorderPane.setMargin(search, new Insets(5));
|
BorderPane.setMargin(search, new Insets(5));
|
||||||
|
|
||||||
|
@ -238,38 +243,32 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (filter == null || filter.isEmpty()) {
|
||||||
gridLock.lock();
|
for (ThumbCell thumbCell : filteredThumbCells) {
|
||||||
try {
|
insert(thumbCell);
|
||||||
if (filter == null || filter.isEmpty()) {
|
|
||||||
for (ThumbCell thumbCell : filteredThumbCells) {
|
|
||||||
insert(thumbCell);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// remove the ones from grid, which don't match
|
// remove the ones from grid, which don't match
|
||||||
for (Iterator<Node> iterator = grid.getChildren().iterator(); iterator.hasNext();) {
|
for (Iterator<Node> iterator = grid.getChildren().iterator(); iterator.hasNext();) {
|
||||||
Node node = iterator.next();
|
Node node = iterator.next();
|
||||||
ThumbCell cell = (ThumbCell) node;
|
ThumbCell cell = (ThumbCell) node;
|
||||||
Model m = cell.getModel();
|
Model m = cell.getModel();
|
||||||
if(!matches(m, filter)) {
|
if(!matches(m, filter)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
filteredThumbCells.add(cell);
|
filteredThumbCells.add(cell);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add the ones, which might have been filtered before, but now match
|
// add the ones, which might have been filtered before, but now match
|
||||||
for (Iterator<ThumbCell> iterator = filteredThumbCells.iterator(); iterator.hasNext();) {
|
for (Iterator<ThumbCell> iterator = filteredThumbCells.iterator(); iterator.hasNext();) {
|
||||||
ThumbCell thumbCell = iterator.next();
|
ThumbCell thumbCell = iterator.next();
|
||||||
Model m = thumbCell.getModel();
|
Model m = thumbCell.getModel();
|
||||||
if(matches(m, filter)) {
|
if(matches(m, filter)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
insert(thumbCell);
|
insert(thumbCell);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
gridLock.unlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +304,9 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
for (String tag : m.getTags()) {
|
for (String tag : m.getTags()) {
|
||||||
searchTextBuilder.append(tag).append(' ');
|
searchTextBuilder.append(tag).append(' ');
|
||||||
}
|
}
|
||||||
|
searchTextBuilder.append(m.getStreamResolution());
|
||||||
String searchText = searchTextBuilder.toString().trim();
|
String searchText = searchTextBuilder.toString().trim();
|
||||||
|
LOG.debug("{} -> {}", m.getName(), searchText);
|
||||||
boolean tokensMissing = false;
|
boolean tokensMissing = false;
|
||||||
for (String token : tokens) {
|
for (String token : tokens) {
|
||||||
if(!searchText.contains(token)) {
|
if(!searchText.contains(token)) {
|
||||||
|
|
Loading…
Reference in New Issue