Skip to content

Commit

Permalink
permissions requesting
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinceOfPuppers committed Dec 3, 2020
1 parent 5c62e43 commit af4f9fa
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions sync_dl_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

import sync_dl.config as cfg
import os

# 0 being off 1 being on as in true / false
# you can use 0 or 1 && True or False
from android.permissions import request_permissions, Permission
import youtube_dl
import shutil
import certifi
from time import sleep

class Main(App):
def build(self):
Expand All @@ -27,23 +29,28 @@ def relSize(self,x,y):
return (2*Window.width*x,2*Window.height*y)


def permissionsGranted():
return check_permission(Permission.READ_EXTERNAL_STORAGE) and check_permission(Permission.WRITE_EXTERNAL_STORAGE)

import youtube_dl
import shutil


def getPermissions():
request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE])

if __name__ == "__main__":
import certifi

os.environ['SSL_CERT_FILE'] = certifi.where()
if kivy.utils.platform == "android":

from android.permissions import request_permissions,check_permission, Permission

if not os.path.exists(cfg.musicDir):
cfg.musicDir = '/storage/emulated/0/Music'
while not permissionsGranted():
sleep(0.1)
getPermissions()


if not os.path.exists(cfg.musicDir):
cfg.musicDir = '/storage/emulated/0/Music'
if not os.path.exists(cfg.musicDir):
raise Exception(f"{cfg.musicDir} Doesnt Exist")


os.environ['SSL_CERT_FILE'] = certifi.where()

cfg.params['quiet'] = True

Expand All @@ -52,8 +59,6 @@ def relSize(self,x,y):
#cfg.params['logger'] = cfg.logger
cfg.params['postprocessors'] = []

if not os.path.exists(cfg.musicDir):
raise Exception(f"{cfg.musicDir} Doesnt Exist")


Main().run()

0 comments on commit af4f9fa

Please sign in to comment.