mirror of
https://github.com/Jonny007-MKD/OTR-SaneRename
synced 2025-01-22 08:49:48 +01:00
Added retreival of information from filename (S00_E00_)
This commit is contained in:
parent
6d2f24e77a
commit
345135acd8
1 changed files with 68 additions and 35 deletions
|
@ -26,7 +26,7 @@
|
||||||
# Config #
|
# Config #
|
||||||
##########
|
##########
|
||||||
apikey="2C9BB45EFB08AD3B"
|
apikey="2C9BB45EFB08AD3B"
|
||||||
productname="SaneRename for OTR (ALPHA) v0.3"
|
productname="SaneRename for OTR (ALPHA) v0.4"
|
||||||
lang="de"
|
lang="de"
|
||||||
debug=false
|
debug=false
|
||||||
|
|
||||||
|
@ -106,6 +106,15 @@ function funcAnalyzeFilename {
|
||||||
if $debug; then echo -e "\033[36mfuncAnalyzeFilename\033[37m"; fi;
|
if $debug; then echo -e "\033[36mfuncAnalyzeFilename\033[37m"; fi;
|
||||||
local tmp;
|
local tmp;
|
||||||
|
|
||||||
|
# Remove series and episode information
|
||||||
|
if [[ "$file_name" == S[0-9][0-9]_E[0-9][0-9]_* ]]; then
|
||||||
|
episode_season="${file_name:1:2}" # Retreive information
|
||||||
|
episode_number="${file_name:5:2}"
|
||||||
|
episode_season=${episode_season#0} # Remove leading 0
|
||||||
|
episode_number=${episode_number#0}
|
||||||
|
file_name="${file_name:8}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Split filename into words, divided by _ (underscores)
|
# Split filename into words, divided by _ (underscores)
|
||||||
file="${file_name//_/ }"
|
file="${file_name//_/ }"
|
||||||
|
|
||||||
|
@ -430,6 +439,24 @@ function funcGetEpisodeInfoByTitle {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
funcGetEpisodeInfo_ParseData
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function funcGetEpisodeInfoBySE {
|
||||||
|
if $debug; then echo -e "\033[36mfuncGetEpisodeInfoBySE\033[37m"; fi;
|
||||||
|
|
||||||
|
wget_file="$PwD/episodes-${series_id}-${langCurrent}.xml"
|
||||||
|
|
||||||
|
episode_info=$(grep -i "bined_episodenumber>$episode_number" "$wget_file" -A 10 | grep -i "bined_season>$episode_season" -B 1 -A 9) # Get XML data
|
||||||
|
|
||||||
|
funcGetEpisodeInfo_ParseData
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function funcGetEpisodeInfo_ParseData {
|
||||||
|
if $debug; then echo -e "\033[36mfuncGetEpisodeInfo_ParseData\033[37m"; fi;
|
||||||
|
|
||||||
if [ -n "$episode_info" ]; then # If we have found something
|
if [ -n "$episode_info" ]; then # If we have found something
|
||||||
episode_number=$(echo -e "$episode_info" | grep -m 1 "Combined_episodenumber") # Get episode number
|
episode_number=$(echo -e "$episode_info" | grep -m 1 "Combined_episodenumber") # Get episode number
|
||||||
episode_season=$(echo -e "$episode_info" | grep -m 1 "Combined_season") # Get season number
|
episode_season=$(echo -e "$episode_info" | grep -m 1 "Combined_season") # Get season number
|
||||||
|
@ -467,6 +494,7 @@ function funcGetEpisodeInfoByTitle {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function funcMakeFilename {
|
function funcMakeFilename {
|
||||||
if $debug; then echo -e "\033[36mfuncMakeFilename\033[37m"; fi;
|
if $debug; then echo -e "\033[36mfuncMakeFilename\033[37m"; fi;
|
||||||
if [ "$lang" == "de" ]; then
|
if [ "$lang" == "de" ]; then
|
||||||
|
@ -499,6 +527,11 @@ function doIt {
|
||||||
funcAnalyzeFilename # Get info from $file_name
|
funcAnalyzeFilename # Get info from $file_name
|
||||||
funcGetSeriesId # Get series ID from cache or TvDB
|
funcGetSeriesId # Get series ID from cache or TvDB
|
||||||
|
|
||||||
|
if [ -n "$episode_season" -a -n "$episode_number" ]; then # We already got info from filename
|
||||||
|
funcGetEpisodeInfoBySE
|
||||||
|
|
||||||
|
else # We have to get info from EPG
|
||||||
|
|
||||||
funcConvertName "$file_title"
|
funcConvertName "$file_title"
|
||||||
if [[ "$tmp" == $series_title_tvdb* ]] || [[ "$file_title" == $series_title_tvdb* ]] ||
|
if [[ "$tmp" == $series_title_tvdb* ]] || [[ "$file_title" == $series_title_tvdb* ]] ||
|
||||||
[[ "$tmp" == $series_alias* ]] || [[ "$file_title" == $series_alias* ]] ; then
|
[[ "$tmp" == $series_alias* ]] || [[ "$file_title" == $series_alias* ]] ; then
|
||||||
|
@ -542,7 +575,7 @@ function doIt {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$episode_info" ] && [ -n "$series_title_tvdb" ]; then
|
if [ -n "$episode_info" ] && [ -n "$series_title_tvdb" ]; then
|
||||||
funcMakeFilename
|
funcMakeFilename
|
||||||
|
|
Loading…
Reference in a new issue