Esempio n. 1
0
def updateAPI(audioFileType, audioFileID):
    if request.method == "PUT":
        res = request.json
        metadata = res.get("audioFileMetadata", None)
        if audioFileType == "song":
            obj = Song()
            if obj.updateItem(database, metadata):
                return success()
            else:
                return notfoundError()

        elif audioFileType == "podcast":
            obj = Podcast()
            if obj.updateItem(database, metadata):
                return success()
            else:
                return notfoundError()

        elif audioFileType == "audiobook":
            obj = Audiobook()
            if obj.updateItem(database, metadata):
                return success()
            else:
                return notfoundError()

        else:
            notfoundError()

    else:
        notfoundError()
Esempio n. 2
0
def deleteAPI(audioFileType, audioFileID):
    if request.method == "DELETE":
        if audioFileType == "song":
            obj = Song()
            if obj.deleteItem(database, audioFileID):
                return success()

            else:
                return notfoundError()

        elif audioFileType == "podcast":
            obj = Podcast()
            if obj.deleteItem(database, audioFileID):
                return success()
            else:
                return notfoundError()

        elif audioFileType == "audiobook":
            obj = Audiobook()
            if obj.deleteItem(database, audioFileID):
                return success()
            else:
                return notfoundError()

        else:
            return notfoundError()

    else:
        return notfoundError()
Esempio n. 3
0
def createAPI():
    if request.method == "POST":
        req = request.json
        audioFileType = req["audioFileType"]
        metadata = req.get("audioFileMetadata", None)
        if audioFileType == "song":
            obj = Song()
            obj.Add(database, metadata)
            return success()

        elif audioFileType == "podcast":
            obj = Podcast()
            if obj.Add(database, metadata):
                return success()
            return notfoundError()

        elif audioFileType == "audiobook":
            obj = Audiobook()
            obj.Add(database, metadata)
            return success()

        else:
            return notfoundError()

    else:
        return notfoundError()
Esempio n. 4
0
 def setUpClass(cls):
     good_reads_soup = BeautifulSoup(open('68429.html'), 'html.parser')
     cls.ab = Audiobook(r'Well of Ascension')
     grs = GoodreadsScraper(good_reads_soup)   
     cls.ab.update_from_goodreads(grs)
     cls.af = Audiofile(r'Well of Ascension\Well of Ascension.mp3')
     cls.af.title = 'Nonsense'
     cls.af.author = 'Mizzle'
     cls.af.series = 'Bizzle'
     cls.af.volume = '#99'
     cls.af.year = '1981'
Esempio n. 5
0
        year = input('Enter the year published: ')
        log = 'Entered year ' + year
        f.write(log + '\n')

        format_f = input('Enter the format of the audiobook: ')
        log = 'Entered format ' + format_f
        f.write(log + '\n')

        try:
            no_item = int(input('Enter the number of copies of the book: '))
            log = 'Entered no of items ' + str(no_item)
            f.write(log + '\n')
        except ValueError:
            print('Sorry, enter an integer')

        items_all['audiobook'][title] = Audiobook(title, genre, price, author,
                                                  year, format_f, no_item)
        log = 'Added an audiobook ' + str(choose_type_add)
        f.write(log + '\n')

        print('Audiobook added!')
        print()

    elif choose_type_add == 3:
        log = 'Choose to add film'
        f.write(log + '\n')

        title = input('Enter film title: ').lower()
        log = 'Entered a film title ' + title
        f.write(log + '\n')

        genre = input('Enter the genre of the film: ')
Esempio n. 6
0
        template = open(ITEM, 'r')
        rss.write(template.read().format(**info))
        template.close()
    template = open(FOOTER, 'r')
    rss.write(template.read())
    template.close()
    rss.close()


if __name__ == "__main__":
    DOWNLOADS = 'downloads'
    LIVE_DOWNLOADS = True #set equal to true after testing
    for direc in get_subfolders(DOWNLOADS):
        d = os.path.join(os.getcwd(), DOWNLOADS, direc)
        print ""
        ab = Audiobook(d)
        print "Started Processing: {}".format(ab.title)
        files = get_files(d)
        if len(files) == 1 and '.mp3' in files[0]:
            af_path = os.path.join(d, files[0])
            af = Audiofile(af_path)
            dl = Downloader()
            url = dl.goodreads_id_query(ab.title)
            print 'Getting Goodreads ID from Google'
            if LIVE_DOWNLOADS:
                results = dl.download_ram(url)
                soup = BeautifulSoup(results, 'html.parser')
                gs = GoogleScraper(soup)
                ab.id = gs.id
            else:
                ab.id = '18007564' #id for the Martian
Esempio n. 7
0
 def test_add_book(self):
     ab = Audiobook(r'Well of Ascension')
     ab.title = 'Well of Ascension'
     ab.series = 'Mistborn'
     ab.volume = '#5'
     ab.author = 'Brandon Sanderson'
     ab.year = 2015
     ab.description = 'A long description ....'
     ab.local_image_url = 'http://image.url.com'
     ab.id = '123456'
     ab.date_added = '4-28-2016'
     ab.duration = 407
     ab.local_url = 'http://www.google.com'
     ab.file_size = 16419170
     ab.deleted = 0
     num_records = self.db.count_records('books')
     self.db.insert_record('books', ab.__dict__)
     self.assertEqual(num_records + 1, self.db.count_records('books'))
Esempio n. 8
0
 def setUpClass(cls):
     cls.ab = Audiobook(r'Well of Ascension')
     cls.af = Audiofile(r'Well of Ascension\Well of Ascension.mp3')