improvements - sub - subscene.com subtitle search
(HTM) git clone git://git.codemadness.org/sub
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 4a19ef447d4320d7fbd1494495a40fa3d7e0846b
(DIR) parent 06e7cb5f254db0b1d9261768542dfcf7c69987f1
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 2 Mar 2018 13:53:45 +0100
improvements
- hide User-Agent in request (privacy).
- use https url standard for searching (no redirect).
- allow http and https url for sub-dl download (allow redirect).
- add README with basic usage information.
Diffstat:
A README | 13 +++++++++++++
M sub-dl | 6 +++---
M sub-search | 7 +++++--
3 files changed, 21 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/README b/README
@@ -0,0 +1,13 @@
+Usage
+=====
+
+ sub-search 'game of thrones s01e02'
+
+This searches only the english subtitles by default.
+
+Now select url of the subtitle.
+
+ sub-dl 'urlhere'
+
+The subtitle is downloaded and unzipped in the current directory: the
+unzip tool is required as a dependency.
(DIR) diff --git a/sub-dl b/sub-dl
@@ -1,11 +1,11 @@
#!/bin/sh
-url=$(curl "$1" | grep -oE '(/subtitle/download\?mac=[^"]*)')
+url=$(curl -L -H 'User-Agent:' "$1" | grep -oE '(/subtitle/download\?mac=[^"]*)')
if test x"$url" = x""; then
exit 1
else
- url="http://subscene.com${url}"
+ url="https://subscene.com${url}"
file="/tmp/sub.$$.zip"
- curl "${url}" > "$file"
+ curl -L -H 'User-Agent:' "${url}" > "$file"
unzip "$file" "*.srt"
fi
(DIR) diff --git a/sub-search b/sub-search
@@ -12,7 +12,10 @@ getep() {
test x"$1" = x"" && usage
query="$1"
-url="http://subscene.com/subtitles/release"
+url="https://subscene.com/subtitles/release"
ep=$(getep "${query}")
-curl --get --data-urlencode "q=${query}" --data-urlencode "r=true" "${url}" | sub | grep -i 'LANG:en' | grep -i "${ep}"
+curl -H 'User-Agent:' --get --data-urlencode "q=${query}" --data-urlencode "r=true" "${url}" | \
+ sub | \
+ grep -i 'LANG:en' | \
+ grep -i "${ep}"