示例#1
0
    def __init__(self,
                 title,
                 author,
                 publish_year,
                 pages,
                 price,
                 language,
                 pages_read=None,
                 status=None,
                 progress=0):
        '''

        :param title:
        :param author:
        :param publish_year:
        :param pages:
        :param price:
        :param language:
        :param pages_read:
        :param status:
        :param progress:
        '''

        # inherent attribute from Media class and initialize
        Media.__init__(self, title, author, publish_year, price, language)

        self.pages = pages
        self.pages_read = pages_read
        self.status = status
        self.progress = progress

        # append attribute of Book class to bookshelf list
        Book.bookshelf.append(self)
def upload_align(audioFilename, transcriptFilename):
    """
    Upload a media file to Koemei for alignment
    NOTE : you will need your account to be setup to use this feature
    """

    # 1) Upload a media file
    inst = Media(accept="text/xml", username=username, password=password, audioFilename=audioFilename, transcriptFilename=transcriptFilename)
    inst.create()

    # extract the uid given to this media item
    if inst.response.code == 200:
        print "Media item has been created successfully"
        search = None
        search = re.search("<id>(.*)</id>", inst.response.read())
        if search is not None:
            uid = str(search.group(1))
            print "The following uid has been extracted: %s" % uid
        else:
            print >> sys.stderr, "An error occured trying to extract the uid"

    else:
        print >> sys.stderr, "-------- An error occurred, response: --------"
        print >> sys.stderr, inst.response.code, inst.response.msg
        print >> sys.stderr, "-------- Headers --------"
        print >> sys.stderr, inst.response.headers

    inst.uid = uid
示例#3
0
    def __init__(self,
                 title,
                 speaker,
                 publish_year,
                 time,
                 price,
                 language,
                 status=None,
                 listen_time=None,
                 progress=0):
        '''
        :param title:
        :param speaker:
        :param publish_year:
        :param time:
        :param price:
        :param language:
        :param status:
        :param listen_time:
        :param progress:
        '''

        # inherent attribute from Media class and initialize
        Media.__init__(self, title, publish_year, price, language)

        self.speaker = speaker
        self.time = time
        self.listen_time = listen_time
        self.status = status
        self.progress = progress

        # append attribute of Podcast_episode class to podcast_shelf list
        Podcast_episode.podcast_shelf.append(self)
示例#4
0
def _create_media_from_row(row):
    if len(row) < 9:
        media = Media(row[0], row[1], row[2], row[3], row[4], row[5], row[6],
                      row[7], 'Null')
    else:
        media = Media(row[0], row[1], row[2], row[3], row[4], row[5], row[6],
                      row[7], row[8])
    return media
 def __init__(self,calln,title_book,subjs,author,descp,publisher,citybook,year,series,notes):
    Media.__init__(self, calln, title_book, subjs, notes)
    self.author = author
    self.descp = descp
    self.publisher = publisher
    self.citybook = citybook
    self.year = year
    self.series = series
示例#6
0
 def __init__(self, media):
     Media.__init__(self, media[0], media[1], media[2], media[3], media[4], media[5], media[7], media[8], media[9])
     self.media = media
     self.episode = media[11]
     self.company = 'company'
     self.subject = 'subject'
     self.genre = 'genre'
     self.duration = 'duration'
 def __init__(self, callno, title, subject, author, description, publisher,
              city, year, series, notes):
     Media.__init__(self, callno, title, subject, notes)
     self.author = author
     self.description = description
     self.publisher = publisher
     self.city = city
     self.year = year
     self.series = series
示例#8
0
def edit_media():
	response.view = 'generic.'+request.extension
	jsonData = simplejson.loads(request.body.read()) if request.body else {}

	from Media import Media
	mediaObj = Media(db)
	if mediaObj.update_media(jsonData['mediaId'], jsonData['fileName'], jsonData['viewLevel'], jsonData['description']):

		return api_response(mediaId=jsonData['mediaId'])
 def __init__(self, calln,title_book,subj,author,descp,publisher,history,seriess,notess,relat_title,othr,gvt):
     Media.__init__(self,calln,title_book,subj,notess)
     self.author = author
     self.descp = descp
     self.publisher =publisher
     self.history = history
     self.seriess = seriess
     self.relat_title = relat_title
     self.othr = othr
     self.gvt =gvt
示例#10
0
 def __init__(self, callno, title, subject, author, description,
              publisher_hist, series, notes, related_title, other_title,
              gov_doc_no):
     Media.__init__(self, callno, title, subject, notes)
     self.author = author
     self.description = description
     self.publisher_hist = publisher_hist
     self.series = series
     self.related_title = related_title
     self.other_title = other_title
     self.gov_doc_no = gov_doc_no
def publish_unpublish(media_uuid):
    """
    Publish and unpublish a media item's transcript.
    Publishing a transcript will make it available to anyone that knowns its uuid
    """
    media_item = Media(accept='text/xml', username=username, password=password, uid=media_uuid)
    media_item.get()
    #from xml.dom import minidom
    #xmldoc = minidom.parseString(media_item.response.read())
    # current_transcript_uuid = xmldoc.getElementsByTagName('currentTranscript')[0].getElementsByTagName('id')[0].firstChild.data
    media_item.publish()
示例#12
0
def remove_media():
	album = {}
	response.view = 'generic.'+request.extension
	mediaID = request.vars.media_id or None
	albumID = request.vars.album_id or None
	from Media import Media
	mediaObj = Media(db)
	from Media import Album
	albumObj = Album(db)
	if mediaObj.remove_media_by_id(mediaID, albumID):
		album = albumObj.get(albumID)

	return api_response(album=album)
示例#13
0
 def __init__(self,
              title,
              author,
              publish_year,
              pages,
              price,
              language,
              pages_read=0,
              status=None,
              progress=0):
     Media.__init__(self, title, author, publish_year, price, language)
     self.pages = pages
     self.pages_read = pages_read
     self.status = status
     self.progress = progress
示例#14
0
def like_media():
	response.view = 'generic.'+request.extension
	reply = False
	mediaID = request.vars.media_id or None
	likeType = request.vars.l_type or None
	from Media import Media
	mediaObj = Media(db)
	if likeType == 'like':
		if mediaObj.like_media(mediaID, session.auth.user.id):
			reply = True;
	else:
		if mediaObj.like_media(mediaID, session.auth.user.id, True):
			reply = True;

	return api_response(success=reply)
示例#15
0
 def __init__(self,
              title,
              speaker,
              publish_year,
              time,
              price,
              language,
              status=None,
              listen_time=0,
              progress=0):
     Media.__init__(self, title, publish_year, price, language)
     self.speaker = speaker
     self.time = time
     self.status = status
     self.listen_time = listen_time
     self.progress = progress
示例#16
0
 def build(self):
     fileext = self.__getExtension()
     mediaName = self.__getMediaNameFromMetaInfo()
     mediaType = self.__getMimeTypeFromMetaInfo()
     mediaDate = self.__getDateFromMetaInfo()
     return Media('METADATA', self.sourceFile, fileext, mediaName,
                  mediaType, mediaDate)
示例#17
0
    def youtube_download(self):
        # Get video
        url = self.gui.getUrl()
        media = Media(url)
        title = html.unescape(media.title)
        self.gui.video_title_text.set(title)

        # Check if downloaded
        if not self.log_contains(title):
            self.gui.status_label_text.set("Downloading song...")
            path = self.get_download_path() + '/%(title)s.%(ext)s'
            media.download(path)
            self.log_add(title)
            self.gui.status_label_text.set("Added to log")

        else:
            self.gui.status_label_text.set("Song already downloaded!")
 def build(self):
     path, filename = split(self.sourceFile)
     fileext = self.__extractExtension(filename)
     mediaName = self.__parseFilename(filename)
     mediaType = MediaUtils.getMediaType(fileext)
     mediaDate = self.__makeUpCreationDateFromFileName(mediaName)
     return Media('FILENAME', self.sourceFile, fileext, mediaName,
                  mediaType, mediaDate)
示例#19
0
 def recently_liked(self):
     """
     Returns the recently liked media by the user.
     """
     medialist = get(self.token,
                     '/users/self/media/liked')
     for data in medialist:
         yield Media(data)
示例#20
0
 def get_recent_media(self):
     """
     Yields a list of recent media objects for this user.
     """
     medialist = get(self.token,
                     '/users/{}/media/recent'.format(self.id))
     for data in medialist:
         media = Media(data)
         yield media
示例#21
0
 def _parseVideo(self,params):
     videoId = params.get('id',None)
     if videoId is not None and videoId.isdigit():
         self.id = str(videoId)
     elif videoId is not None:
         self.id = re.search("\d+",videoId).group(0)
     else:
         self.id = None
     self.title = params.get('title',None)
     self.description = params.get('description',None)
     self.thumbnail = params.get('plmedia$defaultThumbnailUrl',None)
     self.episodeNumber = params.get('pl1$episodeNumber',None)
     self.availableDate = params.get('media$availableDate',None)
     self.expirationDate = params.get('media$expirationDate',None)
     self.programName = params.get('pl1$programName',None)
     keywords = params.get('media$keywords',None)
     if keywords is not None:
         self.keywords = keywords.split(",")
     else:
         self.keywords = None
     self.pubDate = params.get('pubDate',None)
     self.categories = []
     for category in params.get('media$categories',[]):
         self.categories.append(Category(category))
     self.duration = None
     self._media = {}
     self._media['content'] = []
     self._media['thumbnails'] = []
     self._mediaHasUrl = True
     mediaContent = params.get('media$content',[])
     for media in mediaContent:
         mediaObj = Media(media)
         self._media['content'].append(mediaObj)
         if mediaObj.url is None:
             self._mediaHasUrl = False
         if self.duration is None and mediaObj.duration is not None:
             self.duration = mediaObj.duration
     mediaThumbnails = params.get('media$thumbnails',[])
     for media in mediaThumbnails:
         mediaObj = Media(media)
         self._media['thumbnails'].append(mediaObj)
         if mediaObj.url is None:
             self._mediaHasUrl = False
示例#22
0
 def __init__(self):
     pygame.init()  # pygame初期化
     pygame.display.set_mode((1200, 675), 0, 32)  # 画面設定
     self.screen = pygame.display.get_surface()
     pygame.display.set_caption('catch a star game')  # ウィンドウタイトル
     # 各ゲームモードのインスタンスの生成
     self.media = Media()
     self.menu = Menu(self.media)
     self.play = Play(self.media)
     self.setting = Setting(self.media)
     self.bye = Bye(self.media)
     self.ranking = Ranking(self.media)
     self.media.play_bgm(1)
     # 各モードへ分岐するための辞書型
     self.game_mode_list = {
         Mode.MENU: self.menu,
         Mode.PLAY: self.play,
         Mode.SETTING: self.setting,
         Mode.RANKING: self.ranking,
         Mode.BYE: self.bye
     }
示例#23
0
    def recently_liked(self, count=None):
        """
        Yields a list of recently liked media objects by the user.
        Works only if the token is for same user.

        :param count: Count of media to return
        """
        medialist = get(self.token,
                        '/users/self/media/liked',
                        count=10)
        for data in medialist:
            media = Media(data)
            yield media
示例#24
0
def assign_image():
    assignSource = request.vars.page_id
    elementId = int(
        request.vars.element_id) if request.vars.element_id else None
    if not request.vars.image_id == "blank":
        imageId = int(request.vars.image_id) if request.vars.image_id else None
    else:
        imageId = "blank"

    if not assignSource and elementId:
        redirect(URL('editor', 'update', vars=dict(page_id="image")))

    from Media import Media
    media = Media(db)

    if imageId:
        pageRedirect = media.assign_image(imageId, assignSource, elementId)
        if pageRedirect:
            redirect(
                URL('editor',
                    'update',
                    vars=dict(page_id=pageRedirect, element_id=elementId)))
        else:
            redirect(
                URL('editor',
                    'assign_image',
                    vars=dict(page_id=assignSource, element_id=elementId)))

    images = media.get_images()
    form = SQLFORM(
        db.image_library,
        submit_button='Upload',
        fields=['image_name', 'image_desc', 'keywords', 'image_file'],
        formstyle="bootstrap")
    for input in form.elements('input'):
        input['_style'] = 'width:100%'
    form.element('textarea[name=image_desc]')['_style'] = 'width:100%'

    if form.process(formname='form').accepted:
        media.process_key_words(form.vars.id)
        pageRedirect = media.assign_image(form.vars.id, assignSource,
                                          elementId)
        if pageRedirect:
            redirect(
                URL('editor',
                    'update',
                    vars=dict(page_id=pageRedirect, element_id=elementId)))
        else:
            redirect(
                URL('editor',
                    'assign_image',
                    vars=dict(page_id=assignSource, element_id=elementId)))

    return dict(thisPage=THISPAGE, form=form, images=images)
示例#25
0
 def get_recent_media_for_user(self, user_id=None):
     """
     Yields a list of recent media for given user
     :param user_id: User id for which recent media is to be fetched
                     If not provided the user for access token is used
     """
     if user_id:
         medialist = get(self.token,
                         '/users/{}/media/recent'.format(user_id))
     else:
         medialist = get(self.token,
                         '/users/self/media/recent')
     for data in medialist:
         media = Media(data)
         yield media
def prepare_and_download(post_url, dir=None):
    """
        Receives a post_url, verifies it and downloads it.
    """
    if is_accepted_media_url(post_url):
        media = Media(post_url)
        if dir is not None:
            media.set_download_dir(dir)
        print("Downloading: " + media.media_id)
        media.download()
        print("Downloaded: " + media.media_id)
    else:
        print("This link is not valid: " + post_url)
def upload_transcribe(audioFilename):
    """
    Upload a media file to Koemei for transcription
    """

    # 1) Upload a media file
    inst = Media(accept="text/xml", username=username, password=password, audioFilename=audioFilename)
    inst.create()

    # extract the uid given to this media item
    if inst.response.code == 200:
        print "Media item has been created successfully"
        search = None
        search = re.search("<id>(.*)</id>", inst.response.read())
        if search is not None:
            uid = str(search.group(1))
            print "The following uid has been extracted: %s" % uid
        else:
            print >> sys.stderr, "An error occured trying to extract the uid"

    else:
        print >> sys.stderr, "-------- An error occurred, response: --------"
        print >> sys.stderr, inst.response.code, inst.response.msg
        print >> sys.stderr, "-------- Headers --------"
        print >> sys.stderr, inst.response.headers

    inst.uid = uid

    # 2) Request a transcript of the just uploaded media item
    # you should change those 2 callbacks to the url of a handler callback on your website
    inst.transcribe(success_callback_url=None, error_callback_url=None)

    # extract the process id given to this process:
    if inst.response.code == 202:
        print "Transcription has been accepted"
        search = None
        search = re.search(
            '<atom:link href="https://www.koemei.com/REST/media/.*/transcribe/(.*)" rel="self"></atom:link>',
            inst.response.read())
        if search is not None:
            process_id = search.group(1)
            print "The following process id has been extracted: %s" % process_id
        else:
            print >> sys.stderr, "An error occurred trying to extract the process id"

    else:
        print >> sys.stderr, "-------- An error occurred, response: --------"
        print >> sys.stderr, inst.response.code, inst.response.msg
        print >> sys.stderr, "-------- Headers --------"
        print >> sys.stderr, inst.response.headers
    def load_commands_from_db(self):
        # upload commands
        cursor = self.data_base.exec_query("SELECT * FROM Command")
        while cursor.rownumber < cursor.rowcount:
            command_response = cursor.fetchone()
            query = "SELECT name FROM Labels WHERE label_id=%s"
            attached_character_class = \
                self.data_base.exec_template_query(query, [command_response['attached_character_class']]).fetchone()[
                    'name']
            relation_class = ''
            if command_response['relation_class'] is not None:
                relation_class = \
                    self.data_base.exec_template_query(query, [command_response['relation_class']]).fetchone()[
                        'name']

            media_response = self.data_base.exec_query(
                f"SELECT * FROM Media WHERE media_id={command_response['media_id']}").fetchone()
            media = Media(media_response['file_name'], media_response['type'], media_response['duration'])

            trigger_cmd_name = ''
            trigger_cmd_id = command_response['trigger_event_id']
            if trigger_cmd_id is not None:
                trigger_cmd_name = \
                    self.data_base.exec_query(f"SELECT name FROM Command WHERE command_id={trigger_cmd_id}").fetchone()[
                        'name']

            delay = command_response['delay']

            emotion = ''
            emotion_id = command_response['expected_emotion_id']
            if emotion_id is not None:
                emotion = \
                self.data_base.exec_query(f"SELECT name FROM Emotion WHERE emotion_id={emotion_id}").fetchone()['name']

            command = Command(command_response['name'], command_response['centered'],
                              command_response['trigger_event_id'],
                              attached_character_class, relation_class,
                              CommandType(command_response['command_type_id']),
                              trigger_cmd_name, media, command_response['duration'], delay, emotion)
            self.commands.append(command)
示例#29
0
def main():

    username = ""
    password = ""

    from Media import Media

    register_openers()

    # 1) Upload a media file
    inst = Media(accept="text/xml", username=username, password=password, audioFilename="test.mp3")

    inst.create()

    # extract the uid given to this media item
    if inst.response.code == 200:
       print "Media item has been created successfully"
       search = None
       search = re.search("<id>(.*)</id>", inst.response.read())
       if search != None:
          uid = search.group(1)
          uid = str(uid)
          print "The following uid has been extracted: %s" % uid
       else:
          print >> sys.stderr, "An error occured trying to extract the uid"

    else:
       print >> sys.stderr, "-------- An error occurred, response: --------"
       print >> sys.stderr, inst.response.code, inst.response.msg
       print >> sys.stderr, "-------- Headers --------"
       print >> sys.stderr, inst.response.headers

    inst.uid = uid

    # 2) Request a transcript of the just uploaded media item
    inst.transcribe()

    # extract the process id given to this process:
    if inst.response.code == 202:
       print "Transcription has been accepted"
       search = None
       search = re.search('<atom:link href="https://www.koemei.com/REST/media/.*/transcribe/(.*)" rel="self"></atom:link>', inst.response.read())
       if search != None:
          process_id = search.group(1)
          print "The following process id has been extracted: %s" % process_id
       else:
          print >> sys.stderr, "An error occured trying to extract the process id"

    else:
       print >> sys.stderr, "-------- An error occurred, response: --------"
       print >> sys.stderr, inst.response.code, inst.response.msg
       print >> sys.stderr, "-------- Headers --------"
       print >> sys.stderr, inst.response.headers

    time.sleep(5)

    from Process import Process

    inst = Process(accept="text/xml", username=username, password=password, uid=uid, process_id=process_id)

    transcript_ready = False

    while (transcript_ready == False):

         inst.get()

         # extract the progress of this process and if completed the transcript id:
         if inst.response.code == 200:
            transcript = open('transcript.xml', 'w+')
            transcript.write(inst.response.read())
            transcript.close()

            transcript = open('transcript.xml', 'r')
            for e in transcript.readlines():
                e = e.strip()
                search = None
                search = re.search('<progress>(.*)</progress>', e)
                if search != None:
                   print "Transcription still in progress"
                   progress = search.group(1)
                   print "The process is at %s %%" % progress
                   break
            transcript.close()
            # if no progress info has been found, check if the transcript is ready:
            if search == None:
               transcript = open('transcript.xml', 'r')
               for e in transcript.readlines():
                   e = e.strip()
                   search = None
                   search = re.search('<segmentation>', e)
                   if search != None:
                      transcript_ready = True
                      print "Transcription has finished, the transcript has been saved to transcript.xml"
                      break
            transcript.close()
            if search == None:
               print >> sys.stderr, "An error occured trying to extract the progress"

         else:
            print >> sys.stderr, "-------- An error occurred, response: --------"
            print >> sys.stderr, inst.response.code, inst.response.msg
            print >> sys.stderr, "-------- Headers --------"
            print >> sys.stderr, inst.response.headers

         if transcript_ready == False:
            time.sleep(600)
示例#30
0
def update():
    pageSetting = request.vars.page_id or "advanced"
    elementId = int(
        request.vars.element_id) if request.vars.element_id else None
    pageIdError = False
    form = False
    bgForm = False
    images = False
    cards = False
    events = False
    THISPAGE['pageSetting'] = pageSetting
    angularData = False

    from Media import Media
    media = Media(db)

    # ******************BASIC PAGE********************
    if pageSetting == "advanced":
        query = db.basic_site.id > 0
        result = db(query).select().first()
        if result:
            if result.background_img:
                images = media.get_images(result.background_img)
            query = db.basic_site(db.basic_site.id == result.id)
            form = SQLFORM(db.basic_site,
                           query,
                           submit_button='Update',
                           showid=False,
                           fields=[
                               'page_title', 'page_header', 'page_footer',
                               'page_subheader', 'page_tagline', 'page_desc'
                           ],
                           formstyle="bootstrap")
            for input in form.elements('input'):
                input['_style'] = 'width:100%'
            form.element('textarea[name=page_desc]')['_style'] = 'width:100%'
            bgForm = SQLFORM(
                db.basic_site,
                query,
                showid=False,
                submit_button='save background settings',
                fields=['background_color', 'background_img_style'],
                formstyle="bootstrap")
            for input in bgForm.elements('input'):
                input['_style'] = 'width:100%'

            if bgForm.process(formname='bgForm').accepted:
                # redirect(URL('profile', 'broken', vars=dict(account_key=accountKey)))
                redirect(URL('editor', 'update'))

        else:
            form = SQLFORM(db.basic_site,
                           submit_button='Create',
                           fields=[
                               'page_title', 'page_header', 'page_footer',
                               'page_subheader', 'page_tagline', 'page_desc'
                           ],
                           formstyle="bootstrap")
            for input in form.elements('input'):
                input['_style'] = 'width:100%'
            form.element('textarea[name=page_desc]')['_style'] = 'width:100%'

        if form.process(formname='form').accepted:
            redirect(URL('editor', 'update'))

    elif pageSetting == "layout":
        form = False

# ******************CONTENT PAGE********************
    elif pageSetting == "content":
        if not elementId:
            cards = cardDAL.get_content_cards()
            form = SQLFORM(db.content_card,
                           submit_button='Create',
                           fields=['card_name', 'card_heading', 'body_text'],
                           formstyle="bootstrap")
            for input in form.elements('input'):
                input['_style'] = 'width:100%'
            form.element('textarea[name=body_text]')['_style'] = 'width:100%'

            if form.process(formname='form').accepted:
                redirect(URL('editor', 'update', vars=dict(page_id="content")))

        else:
            cards = cardDAL.get_content_cards(elementId)
            if not cards:
                redirect(URL('editor', 'update', vars=dict(page_id="content")))
            query = db.content_card(db.content_card.id == elementId)
            form = SQLFORM(db.content_card,
                           query,
                           submit_button='Update',
                           deletable=True,
                           showid=False,
                           fields=['card_name', 'card_heading', 'body_text'],
                           formstyle="bootstrap")
            for input in form.elements('input'):
                input['_style'] = 'width:100%'
            form.element('textarea[name=body_text]')['_style'] = 'width:100%'

            if form.process(formname='form').accepted:
                redirect(
                    URL('editor',
                        'update',
                        vars=dict(page_id="content", element_id=elementId)))

# ******************EVENT PAGE********************
    elif pageSetting == "event":
        if not elementId:
            events = eventDAL.get_events()
            form = SQLFORM(db.events,
                           submit_button='Create',
                           fields=[
                               'event_name', 'event_heading', 'body_text',
                               'expiration'
                           ],
                           formstyle="bootstrap")
            for input in form.elements('input'):
                input['_style'] = 'width:100%'
            form.element('textarea[name=body_text]')['_style'] = 'width:100%'

            if form.process(formname='form').accepted:
                redirect(URL('editor', 'update', vars=dict(page_id="event")))

        else:
            angularData = {
                "events": eventDAL.get_events(elementId),
                "thisPageID": "event"
            }
            # images=media.g
            events = eventDAL.get_events(elementId)
            if not events:
                redirect(URL('editor', 'update', vars=dict(page_id="event")))
            query = db.events(db.events.id == elementId)
            form = SQLFORM(db.events,
                           query,
                           submit_button='Update',
                           deletable=True,
                           showid=False,
                           fields=[
                               'event_name', 'event_heading', 'body_text',
                               'expiration'
                           ],
                           formstyle="bootstrap")
            for input in form.elements('input'):
                input['_style'] = 'width:100%'
            form.element('textarea[name=body_text]')['_style'] = 'width:100%'

            if form.process(formname='form').accepted:
                redirect(
                    URL('editor',
                        'update',
                        vars=dict(page_id="event", element_id=elementId)))


# ******************IMAGE PAGE********************
    elif pageSetting == "image":
        if not elementId:
            angularData = {"images": media.get_images(), "thisPageID": "image"}
            # images=media.get_images()
            form = SQLFORM(
                db.image_library,
                submit_button='Upload',
                fields=['image_name', 'image_desc', 'keywords', 'image_file'],
                formstyle="bootstrap")
            for input in form.elements('input'):
                input['_style'] = 'width:100%'
            form.element('textarea[name=image_desc]')['_style'] = 'width:100%'

            if form.process(formname='form').accepted:
                media.process_key_words(form.vars.id)
                redirect(URL('editor', 'update', vars=dict(page_id="image")))

        else:
            images = media.get_images(elementId)
            if not images:
                redirect(URL('editor', 'update', vars=dict(page_id="image")))
            query = db.image_library(db.image_library.id == elementId)
            form = SQLFORM(db.image_library,
                           query,
                           submit_button='Update',
                           deletable=True,
                           showid=False,
                           fields=['image_name', 'image_desc', 'keywords'],
                           formstyle="bootstrap")
            for input in form.elements('input'):
                input['_style'] = 'width:100%'
            form.element('textarea[name=image_desc]')['_style'] = 'width:100%'

            if form.process(formname='form').accepted:
                media.process_key_words(form.vars.id)
                redirect(
                    URL('editor',
                        'update',
                        vars=dict(page_id="image", element_id=elementId)))

    else:
        pageIdError = "You are poking around where you dont belong, try something else, or close your browser and login in again"

    return dict(thisPage=THISPAGE,
                form=form,
                bgForm=bgForm,
                images=images,
                cards=cards,
                events=events,
                pageIdError=pageIdError,
                angularData=angularData)
 def __init__(self,calln,title_book,subj,director,notess,year):
     Media.__init__(self,calln,title_book,subj,notess)
     self.director = director
     self.year = year
from Media import Media
import FreshTomato

batmanVsSuperman = Media(
    "BATMAN VS SUPERMAN", "BATMAN Fights with SUPERMAN",
    "http://i1.wp.com/bitcast-a-sm.bitgravity.com/slashfilm/wp/wp-content/images/batman-vs-superman-ew-pics-3-HR.jpg",
    "https://youtu.be/rYi5OPAoceA")

oggy = Media(
    "Oggy and the cockroaches", "Cats fights with cockroaches",
    "http://3.bp.blogspot.com/-hbvMX2E-Eao/Uhmv_XIIh0I/AAAAAAAABho/FhcASFcTF_Y/s400/Oggy+and+the+Cockroaches,+film+team.jpg",
    "https://www.youtube.com/watch?v=POvSDfEyxok")
#oggy.showTrailer()
movies = [oggy, batmanVsSuperman]
FreshTomato.open_movies_page(movies)
示例#33
0
 def __init__(self, callno,title,subject,description,distributor,notes,series,lable):
     Media.__init__(self,callno,title,subject,notes)
     self.description = description
     self.distributor = distributor
     self.series = series
     self.lable = lable
示例#34
0
def build_media_objects(dates, tweets_timestamped):
    media_objects = []
    for i in range(0, len(dates)):
        media_objects.append(Media('Twitter', dates[i], tweets_timestamped[i]))
    return media_objects
示例#35
0
    def __init__(self):
        Window.__init__(self)

        # Initialization of the C++ DirectShow Library
        self.audioFunctions = AudioFunctions()
        self.audioFunctions.InitDirectShow()

        # Media Information
        self.media = Media()

        # The main window
        self.create(100, 100, 700, 300, caption=True, resize=False)

        # Button for 'OpenFile'
        self._openFileButton = TextButton(self)
        self._openFileButton.rect = (0, 0, 50, 30)
        self._openFileButton.text = 'OpenFile'
        self._openFileButton.background = r'Images\Root_button.png'
        self.autoRemove(self._openFileButton.bind('Click', self._onOpenFile))

        # Button for 'Play' and 'Pause'
        self._triggerButton = TextButton(self)
        self._triggerButton.rect = (60, 0, 50, 30)
        self._triggerButton.text = 'Play'
        self._triggerButton.background = r'Images\Root_button.png'
        self.autoRemove(self._triggerButton.bind('Click', self._onTrigger))

        # Button for 'Stop'
        self._stopButton = TextButton(self)
        self._stopButton.rect = (120, 0, 50, 30)
        self._stopButton.text = 'Stop'
        self._stopButton.background = r'Images\Root_button.png'
        self.autoRemove(self._stopButton.bind('Click', self._onStop))

        # Button for 'Remove'
        self._stopButton = TextButton(self)
        self._stopButton.rect = (450, 0, 50, 30)
        self._stopButton.text = 'Remove'
        self._stopButton.background = r'Images\Root_button.png'
        self.autoRemove(self._stopButton.bind('Click', self._onRemove))

        # PlayTime
        self._playTimeText = Text(self)
        self._playTimeText.autosize = True
        self._playTimeText.text = 'PlayTime'
        self._playTimeText.fontSize = 15
        self._playTimeText.xy = (30, 155)

        # Slider for 'playTime'
        self._playTimeSlider = Slider(self)
        self._playTimeSlider.bgColor = color.gray
        self._playTimeSlider.vertical = False
        self._playTimeSlider.rect = (100, 160, 255, 10)
        self._playTimeSlider.thumbMinSize = 10
        self._playTimeSlider.thumbImage = r'Images\ScrollBarThumb.jpg'
        self.autoRemove(
            self._playTimeSlider.bind('Slide', self._onPlayTimeSlide))
        self.autoRemove(
            self._playTimeSlider.bind('Slide Start',
                                      self._onPlayTimeSlideStart))
        self.autoRemove(
            self._playTimeSlider.bind('Slide End', self._onPlayTimeSlideEnd))

        # Slider for 'Volume'
        self._volumeSlider = Slider(self)
        self._volumeSlider.bgColor = color.gray
        self._volumeSlider.vertical = True
        self._volumeSlider.rect = (400, 50, 10, 100)
        self._volumeSlider.thumbMinSize = 10
        self._volumeSlider.thumbImage = r'Images\ScrollBarThumb.jpg'
        self.autoRemove(self._volumeSlider.bind('Slide', self._onVolumeSlide))

        # Volume
        self._volumeText = Text(self)
        self._volumeText.autosize = True
        self._volumeText.text = 'Volume'
        self._volumeText.fontSize = 15
        self._volumeText.xy = (380, 155)

        # Media Information text
        self._mediaInfoText = Text(self)
        self._mediaInfoText.autosize = True
        self._mediaInfoText.fontSize = 15
        self._mediaInfoText.xy = (20, 45)
        self._mediaInfoText.text = 'FileName: \n' \
                                   'Duration: 0 min 0 sec\n'

        # Media Position text
        self._mediaPositionText = Text(self)
        self._mediaPositionText.autosize = True
        self._mediaPositionText.fontSize = 15
        self._mediaPositionText.xy = (20, 80)
        self._mediaPositionText.text = 'Position: 0 min 0 sec\n'

        # Playlist text
        self._playlistText = Text(self)
        self._playlistText.autosize = True
        self._playlistText.text = 'Playlist'
        self._playlistText.fontSize = 15
        self._playlistText.fontColor = color.blue
        self._playlistText.xy = (450, 30)

        # Restore the playlist from disk
        self.playList = {}
        self.workingDir = os.getcwd()  # Locate the current working directory

        try:
            playListFile = open(self.workingDir + r'\PlayList.pickle', 'rb')
        except IOError:
            print '[AudioBoxWindow::__init__] No Playlist File Found'
        else:
            print '[AudioBoxWindow::__init__] Load Playlist File'
            self.playList = pickle.load(
                playListFile)  # Dictionary storing the playlist
            playListFile.close()

        # Radio button group
        self._platListGroup = Group(self)
        self._platListGroup.xy = (450, 50)
        self._platListGroup.size = (200, 500)
        self._platListGroup.autosize = True

        # Display the playlist
        self.mediaButtonList = []
        self._refreshPlayList()

        # Flag indicating if the playTime slider is sliding
        self.playTimeSliding = False

        self.displayAnim = None
        self.displayAnimRunning = False
 def __init__(self, callno, title, subject, director, notes, year):
     Media.__init__(self, callno, title, subject, notes)
     self.director = director
     self.year = year
示例#37
0
class STAR_GAME():
    def __init__(self):
        pygame.init()  # pygame初期化
        pygame.display.set_mode((1200, 675), 0, 32)  # 画面設定
        self.screen = pygame.display.get_surface()
        pygame.display.set_caption('catch a star game')  # ウィンドウタイトル
        # 各ゲームモードのインスタンスの生成
        self.media = Media()
        self.menu = Menu(self.media)
        self.play = Play(self.media)
        self.setting = Setting(self.media)
        self.bye = Bye(self.media)
        self.ranking = Ranking(self.media)
        self.media.play_bgm(1)
        # 各モードへ分岐するための辞書型
        self.game_mode_list = {
            Mode.MENU: self.menu,
            Mode.PLAY: self.play,
            Mode.SETTING: self.setting,
            Mode.RANKING: self.ranking,
            Mode.BYE: self.bye
        }

    '''
    キャラクター表示に関する設定
    '''

    def chara_set(self, screen, difficulty, rect_player, anim_counter):
        # キャラクターがアニメーションするための操作
        anim_counter += 1
        if anim_counter == 360:
            anim_counter = 0
        player_num = round((math.sin(math.radians(anim_counter)) + 1) *
                           1.5)  # 正弦を使ってアニメーションを変化させる
        # 正弦に応じた画像を難易度設定に応じたサイズに変更して表示
        player = pygame.transform.rotozoom(self.media.player_anim[player_num],
                                           0,
                                           0.5 * difficulty[Difficulty.SIZE])

        # 難易度によるキャラクター描画位置ズレ補正
        x, y = rect_player.topleft
        size = (25 * -(difficulty[Difficulty.SIZE] - 2))
        return player, x + size, y + size, anim_counter

    '''
    メインループ
    '''

    def main(self):
        rect_player = self.media.player_anim[0].get_rect()
        rect_player.center = (450, 220)  # プレイヤー画像の初期位置
        difficulty = [2, 2, 2]  # 難易度の初期化
        game_mode = Mode.MENU
        anim_counter = 0
        while True:
            self.screen.blit(self.media.bg[game_mode],
                             self.media.bg[game_mode].get_rect())  # 背景の描画

            # 各ゲームモードへの分岐
            last_game_mode = game_mode
            mode = self.game_mode_list[game_mode]
            game_mode = mode.main(self.screen, difficulty, rect_player)

            # 次ゲームモードが変わるときに初期化を行う
            if last_game_mode == Mode.MENU and game_mode != Mode.MENU:
                self.game_mode_list[game_mode].__init__(self.media)

            # キャラクターの描画
            player, x, y, anim_counter = self.chara_set(
                self.screen, difficulty, rect_player, anim_counter)
            self.screen.blit(player, (x, y))

            pygame.display.update()
示例#38
0
from SidebarCustomize import SidebarCustomize
from SidebarAddItems import SidebarAddItems
from SidebarAddWidgets import SidebarAddWidgets
from Iframe import Iframe
from Media import Media

l = LayoutHorizontal()
i = Iframe()
i.css(
    {
        "width": "100%",
        "height": "calc( 100vh - 5px )",
        "background-color": "gray"
    }, None, ">iframe")

media = Media()

sidebar = SidebarCustomize()
sidebar.Media = media
sidebar2 = SidebarAddItems()
sidebar3 = SidebarAddWidgets()

l.add(sidebar)
l.add(sidebar2)
l.add(sidebar3)
l.add(i)

media.run(s("footer"))
"""
sidebar.run(s("#menu"))
sidebar2.run(s("#submenu"))
 def __init__(self, calln,title_book,subj,descp,distri,notess,seriess,label):
     Media.__init__(self,calln,title_book,subj,notess)
     self.descp = descp
     self.distri = distri
     self.seriess = seriess
     self.label = label