Skip to content

Commit

Permalink
添加根据豆瓣生成简介功能
Browse files Browse the repository at this point in the history
  • Loading branch information
rachpt committed Aug 27, 2018
1 parent 4129361 commit 3f0fdac
Show file tree
Hide file tree
Showing 5 changed files with 659 additions and 24 deletions.
66 changes: 66 additions & 0 deletions get_desc/desc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
# FileName: get_desc/desc.sh
#
# Author: rachpt@126.com
# Version: 2.3v
# Date: 2018-08-27
#
#-------------------------------------#
#
source_detail_desc="${AUTO_ROOT_PATH}/tmp/${dot_name}_desc.txt"
source_detail_html="${AUTO_ROOT_PATH}/tmp/${dot_name}_html.txt"
# import functions
source "$AUTO_ROOT_PATH/get_desc/detail_page.sh"

#---to log and edit.sh---#
if [ -z "$source_site_URL" ]; then
get_source_site # get_desc/detail_page.sh
else
set_source_site_cookie # get_desc/detail_page.sh
fi

#---if not exist desc file---#
if [ ! -s "$source_detail_desc" ]; then
detail_main_func # get_desc/detail_page.sh

subname_tmp_1="$(grep "译[  ]*名" "$source_detail_desc" |sed "s/.*译[  ]*名[  ]*//;s/\n//g;s/\r//g;s/[ ]*//g")"
subname_tmp_2="$(grep "片[  ]*名" "$source_detail_desc" |sed "s/.*片[  ]*名[  ]*//;s/\n//g;s/\r//g;s/[ ]*//g")"

if [ ! "$subname_tmp_1" ] && [ ! "$subname_tmp_2" ]; then
source "$AUTO_ROOT_PATH/get_desc/generate_desc.sh"
generate_main_func # get_desc/generate_desc.sh"
else
#---add site info---#
source_detail_desc_tmp="$(cat "$source_detail_desc")
$(if [ $source_t_id ]; then
echo -e "\n[quote][b]本种简介来自:[/b] ${source_site_URL}/details.php?id=${source_t_id}[/quote]"
else
echo -e "\n[quote][b]本种简介来自:[/b] ${source_site_URL}[/quote]"
fi
)"
source_detail_html_tmp="$(cat "$source_detail_html")
$(echo -e "\n<br /><br /><br /><fieldset><br />\n")
$(if [ $source_t_id ]; then
echo '<span style="font-size:20px;">本种简介来自: '${source_site_URL}/details.php?id=${source_t_id}'</span>'
else
echo '<span style="font-size:20px;">本种简介来自: '${source_site_URL}'</span>'
fi
)$(echo -e "\n<br /></fieldset><br /><br />\n")"

echo "$source_detail_desc_tmp" > "$source_detail_desc"
echo "$source_detail_html_tmp" > "$source_detail_html"
unset source_detail_desc_tmp source_detail_html_tmp
#---
fi
echo "$subname_tmp_1 $subname_tmp_2"

unset subname_tmp_1 subname_tmp_2

unset avoid_infinite_loops chs_name_douban desc_json_info
unset tmp_poster_file new_poster_url new_poster_url_byrbt
fi

#---poster---#
sed -i "1 {s/^[ \t]*//g}" "$source_detail_desc"
source "$AUTO_ROOT_PATH/get_desc/poster.sh"
cat "$source_detail_html"
39 changes: 15 additions & 24 deletions get_desc/detail_page.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# FileName: get_desc/detail_page.sh
#
# Author: rachpt@126.com
# Version: 2.2v
# Date: 2018-06-28
# Version: 2.3v
# Date: 2018-08-22
#
#-------------------------------------#
get_source_site()
Expand All @@ -13,16 +13,18 @@ get_source_site()
if [ "`echo $tracker_source_infos|grep -i 'hdsky'`" ]; then
source_site_URL='https://hdsky.me'
cookie_source_site="$cookie_hds"
echo "got source_site" >> "$log_Path"
elif [ "`echo $tracker_source_infos|grep -i 'totheglory'`" ]; then
source_site_URL='https://totheglory.im'
cookie_source_site="$cookie_ttg"
echo "got source_site" >> "$log_Path"
elif [ "`echo $tracker_source_infos|grep -i 'hdchina'`" ]; then
source_site_URL='https://hdchina.org'
cookie_source_site="$cookie_hdc"
echo "got source_site" >> "$log_Path"
#elif [ "`echo $tracker_source_infos|grep -i 'new'`" ]; then
# source_site_URL='https://new.tracker.com'
fi
echo "got source_site" >> "$log_Path"
}
set_source_site_cookie()
{
Expand Down Expand Up @@ -128,41 +130,30 @@ form_source_site_get_Desc()
cat "$source_detail_desc" > "$source_detail_html"

imdbUrl="$(grep -o 'tt[0-9]\{7\}' "$source_detail_full"|head -n 1)"
doubanUrl="$(grep -o 'http[s]*://movie\.douban\.com/subject/[0-9]\{8\}[/]*' "$source_detail_full"|head -n 1)"

#---html2bbcode---#
source "$AUTO_ROOT_PATH/get_desc/html2bbcode.sh"
source "$AUTO_ROOT_PATH/get_desc/html2bbcode.sh"

fi
rm -f "$source_detail_full"
}

#-------------------------------------#
detail_main_func()
{
#---use dot name save desc---#
dot_name=`echo "$new_torrent_name"|sed "s/[ ]\+/./g;s/\(.*\)\.mp4/\1/g;s/\(.*\)\.mkv/\1/g"`
#---define temp file name---#
source_detail_full="${AUTO_ROOT_PATH}/tmp/${dot_name}_full.txt"
source_detail_desc="${AUTO_ROOT_PATH}/tmp/${dot_name}_desc.txt"
source_detail_html="${AUTO_ROOT_PATH}/tmp/${dot_name}_html.txt"

if [ ! -s "$source_detail_desc" ]; then
#---deal with called from edit.sh---#
if [ -z "$source_site_URL" ]; then
get_source_site
else
set_source_site_cookie
fi
#---get description---#
if [ "$source_site_URL" = "https://hdsky.me" ]; then
#---use rss page first---#
source "$AUTO_ROOT_PATH/get_desc/hdsky_rss.sh"
else
#---mormal method---#
form_source_site_get_Desc
fi
#---get description---#
if [ "$source_site_URL" = "https://hdsky.me" ]; then
#---use rss page first---#
source "$AUTO_ROOT_PATH/get_desc/hdsky_rss.sh"
else
#---mormal method---#
form_source_site_get_Desc
fi
}

#-------------------------------------#
detail_main_func

Loading

0 comments on commit 3f0fdac

Please sign in to comment.