Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPS error, and option to select some or all files in playlist #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Python/GV Downloader.exe
Binary file not shown.
92 changes: 30 additions & 62 deletions Python/GV Downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,23 @@
yes_list = ["Y", "y", "yes", "Yes", "YES", "True"]
no_list = ["N", "n", "no", "No", "NO", "False"]


print ("Please follow the on screen prompts.")



g.msgbox ("Vaheguru Jee Kaa Khalsa Vaheguru Jee Kee Fateh \n"
"Please make sure that you have already downloaded a playlist.m3u file for which tracks you would like to download. You will be prompted to select the file.", "GV Downloader")

#print ("Vaheguru Jee Kaa Khalsa Vaheguru Jee Kee Fateh")
#print ("gv-downloader")

#input("The downloader will now ask you to select the playlist.m3u file you have downloaded for which tracks you would like to download. Please press enter to continue...")

path = g.fileopenbox()


file = open (path, "r")
contents = file.read()
print(" ")
print (("Reading file ") + (os.path.basename(file.name)))



if (os.path.basename(file.name)) != "playlist.m3u":
oui_2 = g.ynbox(("You selected the file ")+ (os.path.basename(file.name)) + ("\n") +
("Are you sure this is the file you meant to select? If yes, the downloader will continue. If no, you will be prompted to select a file again."), "GV Downloader")
#print (("You selected the file ") + (os.path.basename(file.name)))
#oui = input ("Are you sure this is the file you meant to select? If yes, the downloader will continue. If no, you will be prompted to select a file again. ")



if oui_2 == ("True"):
pass
elif oui_2 == ("False"):
Expand All @@ -46,23 +33,7 @@
file = open (path, "r")
contents = file.read()



#if oui in yes_list:
# pass
#elif oui in no_list:
# path = easygui.fileopenbox()

# file = open (path, "r")
# contents = file.read()

#else:
# pass






split_lines = contents.split()

playlist_length = (len(split_lines))
Expand All @@ -73,25 +44,40 @@

print("This playlist has " , playlist_length , file_plur)

#subfolder_name = input ("What would you like to name the subfolder into which the " + (file_plur) + " will be saved into? ")

g.msgbox ("Please select the folder into which you would like the " + (file_plur) + " to be saved to.", "GV Downloader")

chosen_dir = g.diropenbox()

subfolder_name = chosen_dir

list_to_choose = []

for each in split_lines:
list_to_choose.append(each)

chooser_msg = "Please choose the tracks that you would like to download. Click on individual tracks to select/deselect."
chooser_title = "Kirtan Downloader"
chooser_choices = list_to_choose
chooser_chosen = g.multchoicebox(chooser_msg, chooser_title, chooser_choices)

playlist_length = (len(chooser_chosen))

if playlist_length > 1:
file_plur = "files"
if playlist_length == 1:
file_plur = "file"

#try:
# # Create target folder
# os.mkdir(subfolder_name)
# print("Directory " , subfolder_name , " Created ")
#except FileExistsError:
# print("Directory " , subfolder_name , " already exists")
print(" ")
print("Now downloading " , playlist_length , file_plur)
print(" ")
print("Downloading " + file_plur)
for url in split_lines:

for url in chooser_chosen:
try:
site = urlopen(url)
except:
if "https" in url:
print("welp")
else:
url = url.replace("http://","https://")
site = urlopen(url)
meta = site.info()

Expand All @@ -109,7 +95,7 @@
already_size = os.path.getsize(name)

if already_size == total_size:
print("The file " + file_name + " already exists. Continueing with next file...")
print("The file " + file_name + " already exists. Continuing with next file...")
continue

elif already_size != total_size:
Expand All @@ -126,18 +112,9 @@
f.write(data)
t.close()
print ("File downloaded: " + file_name)







if total_size != 0 and t.n != total_size:
print("ERROR, something went wrong")




elif not (os.path.exists(name)):
print("Downloading " + file_name)
Expand All @@ -154,22 +131,13 @@
t.close()

print ("File downloaded: " + file_name)


if total_size != 0 and t.n != total_size:
print("ERROR, something went wrong")



print(" ")
print("Downloading finished.")



g.msgbox (("Downloads complete. Downloader will now close.") , "GV Downloader")


exit()



exit()
108 changes: 99 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Gurmat Veechar Downloader

Quickly download large amounts of katha and keertan from GurmatVeechaar.com and other websites with one click.
Quickly download large amounts of katha and keertan from GurmatVeechar.com and other websites with one click

[https://github.com/gursevak/gv-downloader](https://github.com/gursevak/gv-downloader)


## About

These scripts work with any m3u playlist file and allows batch downloading of all the files in the playlist.

The provided sample `playlist.m3u` file contains the complete [Larivaar Siri Guru Granth Sahib Ji Katha by Sant Giani Gurbachan Singh Ji Bhindranwale](http://www.gurmatveechar.com/audio.php?q=f&f=%2FKatha%2F01_Puratan_Katha%2FSant_Gurbachan_Singh_%28Bhindran_wale%29%2FGuru_Granth_Sahib_Larivaar_Katha)


## Supported Websites

Expand All @@ -12,19 +22,96 @@ Quickly download large amounts of katha and keertan from GurmatVeechaar.com and
- [japtapsamagams.com](https://www.japtapsamagams.com/)
- [gurunanakacademy.com](http://gurunanakacademy.com)
- [rajkaregakhalsa.net](https://www.rajkaregakhalsa.net/)
- anything other website that provides .m3u playlist files

## About

These scripts work with any m3u playlist file and allows batch downloading of all the files in the playlist.
## Windows Instructions

1. Download the `playlist.m3u` file for the playlist or folder that you want to download. Playlist files can usually be found on most katha/keertan websites: go to the folder or playlist that you want to download and look for a green 'play button' icon near the top of the folder.

2. Download the `GVDOWNLOADER1.2.2` release [click here](https://github.com/themanjotsingh/gv-downloader/releases/tag/1.2.2). Ignore warnings from your web browser or Windows Defender. It shows this because of the exe not being signed as well as not being a commonly downloaded file.

3. Run `GV Downloader.exe`. Follow the on screen prompts.

4. When asked, locate the playlist.m3u file you downloaded earlier.

4. When asked, enter a name for the sub-directory that you would like to create to put this playlist's files in.

5. You can choose if you'd like to download some tracks in th playlist, or select all.

6. The downloader will begin downloading files into the directory you chose. It will also check if that file already exists before downloading again in case you need to stop downloading for whatever reason and need to resume later on therefore having to not redownload already downloaded files.


## MacOS Instructions

1. Download the `playlist.m3u` file for the playlist or folder that you want to download. Playlist files can usually be found on most katha/keertan websites: go to the folder or playlist that you want to download and look for a green 'play button' icon near the top of the folder.

2. Download the `Source` ZIP file [click here](https://github.com/gursevak/gv-downloader/releases/tag/1.2.1), unzip the folder and replace the provided `playlist.m3u` file with the file that you just downloaded in the `Terminal` Folder.

3. Open `Terminal.app` and drag-and-drop the `download.sh` file into the Terminal window to open it. Terminal: Applications/Utilities (or search for it).

4. Press the `Enter` key once. Then follow the on-screen instructions and begin downloading. You can quit the program at any time by pressing `CTR+C` (`^+C`) on your keyboard or by closing the window.

When you restart, the program will automatically begin with the file that you left off at (and remove the already downloaded files from `playlist.m3u`)

**If the script isn't running, you *may* need to change the file's permissions to run the script. To do this, copy/paste the following line into Terminal
`cd "$(dirname "$0")" chmod a+x download.sh` and press enter.


## Python Instructions (Mac + Windows)

Prerequisites:
Python 3.5 or later

1. Download the `playlist.m3u` file for the playlist or folder that you want to download. Playlist files can usually be found on most katha/keertan websites: go to the folder or playlist that you want to download and look for a green 'play button' icon near the top of the folder.

2. Download the `Source` ZIP file [click here](https://github.com/gursevak/gv-downloader/releases/tag/1.2.1), unzip the folder and replace the provided `playlist.m3u` file with the file that you just downloaded in the `Python` Folder.

3. Run the `GV Downloader.py` file. Follow the on screen prompts.

4. When asked, locate the playlist.m3u file you downloaded earlier.

5. When asked, select the folder that you would like to create to put this playlist's files in.

5. The downloader will begin downloading files into the directory you chose. It will also check if that file already exists before downloading again in case you need to stop downloading for whatever reason and need to resume later on therefore having to not redownload already downloaded files.


## Windows Powershell Intructions

1. Download the `playlist.m3u` file for the playlist or folder that you want to download. Playlist files can usually be found on most katha/keertan websites: go to the folder or playlist that you want to download and look for a green 'play button' icon near the top of the folder.

2. Download the `Source` ZIP file [click here](https://github.com/gursevak/gv-downloader/releases/tag/1.2.1), unzip the folder and replace the provided `playlist.m3u` file with the file that you just downloaded in the `Powershell` Folder.

3. Right click on `Powershell.ps1` and then click on "Run with Powershell" in the Right Click Context Menu.


## [optional] Using the Bash Script on Windows 10

Optionally, the `download.sh` script can be used on Windows as well using the following instructions:

1. Install WSL or Windows Subsystem for Linux:

Go to Settings > Update & Security > For Developers. Check the Developer Mode radio button. And search for “Windows Features”, choose “Turn Windows features on or off”.

2. Scroll to find WSL, check the box, and then install it. Once done, one has to reboot to finish installing the requested changes. Press Restart now.

3. BASH will be available in the Command Prompt and PowerShell where you can execute the script.




-----------------------
Windows executable made with [Auto PY to EXE](https://github.com/brentvollebregt/auto-py-to-exe)

Uses [tqdm](https://github.com/tqdm/tqdm) [easygui](https://easygui.readthedocs.io/en/master/) [requests](https://requests.readthedocs.io/en/master/)

The provided sample `playlist.m3u` file contains the complete [Larivaar Siri Guru Granth Sahib Ji Katha by Sant Giani Gurbachan Singh Ji Bhindranwale](http://www.gurmatveechar.com/audio.php?q=f&f=%2FKatha%2F01_Puratan_Katha%2FSant_Gurbachan_Singh_%28Bhindran_wale%29%2FGuru_Granth_Sahib_Larivaar_Katha)


## Windows Instructions

1. Download the `playlist.m3u` file for the playlist or folder that you want to download. Playlist files can usually be found on most katha/keertan websites: go to the folder or playlist that you want to download and look for a green 'play button' icon near the top of the folder.

2. Download the `GVDOWNLOADER1.2.1` release [click here](https://github.com/themanjotsingh/gv-downloader/releases/tag/1.2.1). Ignore warnings from your web browser or Windows Defender. It shows this because of the exe not being signed as well as not being a commonly downloaded file (generally speaking).
2. Download the `GVDOWNLOADER1.2.1` release [click here](https://github.com/gursevak/gv-downloader/releases/tag/1.2.1). Ignore warnings from your web browser or Windows Defender. It shows this because of the exe not being signed as well as not being a commonly downloaded file (generally speaking).

3. Run `GVDOWNLOADER1.2.1.exe`. Follow the on screen prompts.

Expand All @@ -37,17 +124,17 @@ The provided sample `playlist.m3u` file contains the complete [Larivaar Siri Gur

## MacOS Instructions


1. Download the `playlist.m3u` file for the playlist or folder that you want to download. Playlist files can usually be found on most katha/keertan websites: go to the folder or playlist that you want to download and look for a green 'play button' icon near the top of the folder.

2. Download the script using the link above (Download ZIP), unzip the folder and replace the provided `playlist.m3u` file with the file that you just downloaded in the `Terminal` Folder.
2. Download the `Source` ZIP file [click here](https://github.com/gursevak/gv-downloader/releases/tag/1.2.1), unzip the folder and replace the provided `playlist.m3u` file with the file that you just downloaded in the `Terminal` Folder.

3. Open `Terminal.app` and drag-and-drop the `download.sh` file into the Terminal window to open it. Terminal: Applications/Utilities (or search for it).

4. Press the `Enter` key once. Then follow the on-screen instructions and begin downloading. You can quit the program at any time by pressing `CTR+C` (`^+C`) on your keyboard or by closing the window.

When you restart, the program will automatically begin with the file that you left off at (and remove the already downloaded files from `playlist.m3u`)

-----------------------
**If the script isn't running, you *may* need to change the file's permissions to run the script. To do this, copy/paste the following line into Terminal
`cd "$(dirname "$0")" chmod a+x download.sh` and press enter.

Expand All @@ -59,7 +146,7 @@ Python 3.5 or later

1. Download the `playlist.m3u` file for the playlist or folder that you want to download. Playlist files can usually be found on most katha/keertan websites: go to the folder or playlist that you want to download and look for a green 'play button' icon near the top of the folder.

2. Download the script using the link above (Download ZIP), unzip the folder and replace the provided `playlist.m3u` file with the file that you just downloaded in the `Python` Folder.
2. Download the `Source` ZIP file [click here](https://github.com/gursevak/gv-downloader/releases/tag/1.2.1), unzip the folder and replace the provided `playlist.m3u` file with the file that you just downloaded in the `Python` Folder.

3. Run the `GV Downloader.py` file. Follow the on screen prompts.

Expand All @@ -74,11 +161,14 @@ Python 3.5 or later

1. Download the `playlist.m3u` file for the playlist or folder that you want to download. Playlist files can usually be found on most katha/keertan websites: go to the folder or playlist that you want to download and look for a green 'play button' icon near the top of the folder.

2. Download the script using the link above (Download ZIP), unzip the folder and replace the provided `playlist.m3u` file with the file that you just downloaded in the `Powershell` Folder.
2. Download the `Source` ZIP file [click here](https://github.com/gursevak/gv-downloader/releases/tag/1.2.1), unzip the folder and replace the provided `playlist.m3u` file with the file that you just downloaded in the `Powershell` Folder.

3. Right click on `Powershell.ps1` and then click on "Run with Powershell" in the Right Click Context Menu.


## [optional] Using the Bash Script on Windows 10

Optionally, the `download.sh` script can be used on Windows as well using the following instructions:
## Using the Bash Script on Windows 10

The `download.sh` script can be used on Windows as well using the following instructions:
Expand Down