# Подключаемся к WebDAV диску
webdav_client = Client({
'webdav_hostname': webdav_url,
'webdav_login': webdav_username,
'webdav_password': webdav_password
})
def calculate_hash(file_path):
hash_md5 = hashlib.md5()
with open(file_path, 'rb') as f:
for chunk in iter(lambda: f.read(4096), b''):
hash_md5.update(chunk)
return hash_md5.hexdigest()
hash_remote = calculate_hash(webdav_url + '/' + filename)
Error uploading file: [Errno 22] Invalid argument: 'https://webdav.cloud.mail.ru/IMG_6447_1.JPG'
hash_remote = calculate_hash(webdav_client.info(filename))
не работает. params = {
"text": 'russia',
"day": 1,
"month": 1,
"offset": 1,
}
param_str = urlencode(params)
# формируем полную ссылку
api_url = f'https://api.api-ninjas.com/v1/historicalevents?{param_str}'
#print(api_url)
response = requests.get(api_url, headers={'X-Api-Key': }
[{"year": "1860", "month": "01", "day": "01", "event": "The first Polish stamp is issued, replacing the Russian stamps previously in use."}, {"year": "1998", "month": "01", "day": "01", "event": "Following a currency reform, Russia begins to circulate new rubles to stem inflation and promote confidence."}, {"year": "2015", "month": "01", "day": "01", "event": "The Eurasian Economic Union comes into effect, creating a political and economic union between Russia, Belarus, Armenia, Kazakhstan and Kyrgyzstan."}]
event = [The first Polish stamp is issued, replacing the Russian stamps previously in use. Following a currency reform, Russia begins to circulate new rubles to stem inflation and promote confidence. The Eurasian Economic Union comes into effect, creating a political and economic union between Russia, Belarus, Armenia, Kazakhstan and Kyrgyzstan.]
api_url = 'https://api.api-ninjas.com/v1/historicalevents?text={}&day={}&month={}'.format(text&day&month)
такой вариант ? {"fact":{"pressure_mm":761,"condition":"clear","temp":24,"wind_dir":"n","pressure_pa":1014,"humidity":54,"polar":false,"daytime":"d","season":"summer","obs_time":1686819600,"feels_like":24,"icon":"skc_d","wind_gust":6.7999999999999998,"wind_speed":2,"temp_water":20},"forecast":{"sunset":"22:16","moon_text":"moon-code-6","parts":[{"pressure_mm":760,"pressure_pa":1013,"part_name":"evening","temp_avg":23,"wind_dir":"n","humidity":35,"prec_prob":0,"prec_period":240,"condition":"clear","daytime":"d","polar":false,"wind_gust":6.2999999999999998,"icon":"skc_d","feels_like":21,"temp_min":19,"wind_speed":2.2999999999999998,"prec_mm":0,"temp_max":25,"temp_water":21},{"pressure_mm":759,"pressure_pa":1011,"part_name":"night","temp_avg":9,"wind_dir":"sw","humidity":77,"prec_prob":0,"prec_period":480,"condition":"clear","daytime":"n","polar":false,"wind_gust":2.3999999999999999,"icon":"skc_n","feels_like":7,"temp_min":7,"wind_speed":1,"prec_mm":0,"temp_max":13,"temp_water":20}],"moon_code":6,"date_ts":1686776400,"date":"2023-06-15","week":24,"sunrise":"03:28"},"info":{"url":"https:\/\/yandex.ru\/pogoda\/98620?lat=59.99233&lon=32.03388","lat":59.992330000000003,"lon":32.033880000000003},"now":1686822516,"now_dt":"2023-06-15T09:48:36.641592Z"}
function prepare(){
for value in "${@}"
do
find "$@" -not -iname "*!qB" -o -not -iname "*!ut" | sort -r | while read file; do RENAME=$(dirname "$file")/$(echo $(basename "$file") | sed -f "$Template" );
if [[ "$file" != "$RENAME" ]];
then
mv -fv "$file" "$RENAME" && sleep 0.1s || exit_stop 0
fi
Massive_file=`echo ${file[@]} ${RENAME[@]} | tr ' ' '\n' | sort | uniq -u`
done
done
if [[ "$file" == "$RENAME" ]] && [[ "$Massive_file" == "" ]];
then
find_file "${@}"
fi
}
function find_file(){
for value in "${@}"
do
x="$IFS";IFS=$'\n';for File in $(find "$@" -regex "$ExVideo" -o -regex "$ExMusic" | sort -u );
do
IFS="$x"
if [[ -n "${File[@]}" ]];
then get_names "${File[@]}"
fi
done
done
}
function rename(){
for value in "${@}"
do
if [[ -n "$@" ]];
then
NEWNAME=$( echo "${@}" | sed -f "$Template" )
mv -fv "${@}" "$NEWNAME"
fi
done
}
function get_names(){
for value in "${@}"
do
WhatFolder_all_address=$(dirname "${@}" );
RootFolder=$(dirname "$WhatFolder_all_address" | sed s'/\/\/[^/]//'g );
WhatFolder=$(dirname "${@}" );
FileName=$(basename "${@}" );
Extension=${FileName##*.};
FOLDER=$(echo "$Downloads")/$(echo "${@}" | cut -d '/' -f 5 ) ;
ARTIST_FOLDER=$(echo "${@}" | cut -d '/' -f 5 ) ;
done
if [[ -n "$WhatFolder_all_address" ]] && [[ -n "$RootFolder" ]] && [[ -n "$WhatFolder" ]] && [[ -n "$FileName" ]] && [[ -n "$Extension" ]] && [[ -n "$FOLDER" ]];
then
type_media "${@}"
fi
}
function type_media(){
for value in "${@}"
do
# немножко цвета
Red='\e[1;31m'
Green='\e[1;32m'
Blue='\e[1;34m'
Black='\e[0;30m'
DarkGray='\e[1;30m'
Light_Red='\e[1;31m'
Light_Green='\e[1;32m'
Brown_Orange='\e[0;33m'
Yellow='\e[1;33m'
Light_Blue='\e[1;34m'
Purple='\e[0;35m'
Light_Purple='\e[1;35m'
Cyan='\e[0;36m'
Light_Cyan='\e[1;36m'
Light_Gray='\e[0;37m'
White='\e[1;37m'
# отмена цвета
NC='\e[0m'
#echo -e ${Brown_Orange}"type_media"${NC}
if [[ -n "$Extension" ]];
then
if [[ "$ExVideo" =~ "$Extension" ]];
then
#echo -e "Обнаружены ${Cyan}VIDEO${NC} файлы."
#echo "${file[@]}"
sort_video "${@}"
fi
if [[ "$ExMusic" =~ "$Extension" ]];
then
#echo -e "Обнаружены ${Yellow}LOSSLESS${NC} файлы."
#echo "${file[@]}"
sort_music "${@}"
fi
fi
done
}
function convert_video(){
# convert video
for value in "${@}"
do ffmpeg -y -i "$@" -sn "${@%.*}.mkv" ; rm -rf "$@" || rm -rf "${@%.*}.mkv"; done
}
function convert_music(){
#echo -e ${Light_Cyan}"Начинаю конвертацию FLAC"${NC}
for value in "${@}"
do
#convert music
#echo -e "Обнаружены ${Yellow}CUE${NC} файлы."
#echo -e "Convert ${Yellow}FLAC ${NC}файлов."
# перекодирует CUE файл в UTF8 cp1251
dos2unix "$CUEFILE"
enconv -L russian -x utf8 "$CUEFILE" && echo "success $?" || enconv -c -x utf8 "$CUEFILE"
# получаем жанр и год из CUE файла.
function parsecue(){
GENRE=$(head -n 6 "$CUEFILE" | grep -i GENRE | sed "s/REM GENRE //i" )
DATE=$(head -n 6 "$CUEFILE" | grep -i "DATE" | sed "s/REM DATE //i" )
}
# распилим его на отдельные FLAC части
cuebreakpoints "$CUEFILE" | shnsplit -o flac -d "$TempMusic" "$File"
# проставим тэги из CUE в новые FLAC части.
cuetag "$CUEFILE" "$TempMusic"/split-track*.flac ;
# напарсим не хватающих тэгов жанра и года выпуска из CUE файла.
parsecue
# впишем тэги и приведём имена файлов нарезанных частей в человеческий вид
for SLICE in "$TempMusic"/split-track*.flac;
do
metaflac --set-tag "GENRE=$GENRE" --set-tag "DATE=$DATE" "$SLICE"
ARTIST=$(metaflac "$SLICE" --show-tag=ARTIST | sed s/.*=//g)
TITLE=$(metaflac "$SLICE" --show-tag=TITLE | sed s/.*=//g)
TRACKNUMBER=$(metaflac "$SLICE" --show-tag=TRACKNUMBER | sed s/.*=//g)
TRACKNAME=$(echo "$TRACKNUMBER - $TITLE.flac" | sed -f "$Template")
mv -fv "$SLICE" "$TempMusic"/"$TRACKNAME"
done
sleep 0.5s
clean "$WhatFolder_all_address"/*
sleep 2s
mv "$TempMusic"/* "$WhatFolder_all_address"/
#exit_stop 0
done
}
wsl /mnt/c/Users/MissAnastasiia/Script/start.sh
-> '/mnt/d/Serials/Falshivyj.flag.S01.2019'
(wsl /mnt/c/Users/MissAnastasiia/Script/start.sh) | -replace ‘.*Downloads (.*)', '-> $1’
renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E08.2019.WEB-DL.1080p.mkv' -> '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E08.2019.mkv' renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E07.2019.WEB-DL.1080p.mkv' -> '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E07.2019.mkv' renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E06.2019.WEB-DL.1080p.mkv' -> '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E06.2019.mkv' renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E05.2019.WEB-DL.1080p.mkv' -> '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E05.2019.mkv' renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E04.2019.WEB-DL.1080p.mkv' -> '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E04.2019.mkv' renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E03.2019.WEB-DL.1080p.mkv' -> '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E03.2019.mkv' renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E02.2019.WEB-DL.1080p.mkv' -> '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E02.2019.mkv' renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E01.2019.WEB-DL.1080p.mkv' -> '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p/Falshivyj.flag.S01.E01.2019.mkv' renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019.WEB-DL.1080p' -> '/mnt/d/Downloads/Falshivyj.flag.S01.2019' renamed '/mnt/d/Downloads/Falshivyj.flag.S01.2019' -> '/mnt/d/Serials/Falshivyj.flag.S01.2019'
5 B C A B 0 = > 2 ; 5 = = K E 4 8 A B @ 8 1 C B 8 2 > 2 ? > 4 A 8 A B 5 < K W i n d o w s 4 ; O L i n u x . 8 A B @ 8 1 C B 8 2 K < > 6 = > C A B 0 = > 2 8 B L 8 7 M i c r o s o f t S t o r e : h t t p s : / / a k a . m s / w s l s t o r e