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

Fixed #55 '--video option breaks when used' #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 12 additions & 5 deletions moboff.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import json
from sys import version_info
import shutil

from pushbullet import Pushbullet
import pushbullet
Expand All @@ -14,6 +15,7 @@

real_path_of_MobOff = os.path.dirname(os.path.realpath(__file__))


if version_info[0] == 2:
rawinput = raw_input
else:
Expand Down Expand Up @@ -50,6 +52,7 @@ def cli():
@click.option('--send', is_flag=bool, default=False,
help='Send the file to a friend.')


def download(link, newdevice, video, delete,send):
"""Download a youtube video or playlist
in best audio and video quality
Expand Down Expand Up @@ -107,8 +110,11 @@ def download(link, newdevice, video, delete,send):
click.secho("The directory previously selected to download music can't be accessed."
" Please rerun moboff initialise.")
quit()

os.mkdir("{0}/temp".format(directory))

try:
os.mkdir("{0}/temp".format(directory))
except OSError as err:
print(err)
os.chdir("{0}/temp".format(directory))

print("This may take a while.")
Expand Down Expand Up @@ -174,9 +180,10 @@ def download(link, newdevice, video, delete,send):

for file in list_of_files:
if file.endswith((".mp3", "mp4", ".mkv")):
os.rename("{0}/temp/{1}".format(directory, file),"{0}/{1}".format(directory, file))

os.rmdir("{0}/temp".format(directory))
os.rename("{0}/temp/{1}".format(directory, file), "{0}/{1}".format(directory, file))

#os.rmdir("{0}/temp".format(directory))
shutil.rmtree("{0}/temp".format(directory))
os.chdir(directory)

if delete:
Expand Down