Example #1
0
def detail(path):
    host = request.headers.get('Host')
    detail = {
        "photos":
        find_file(path,
                  ".jpg",
                  web_dir="//%s/ddd/" % host,
                  filter_word="QR-1024"),
        "movies":
        find_file(path,
                  ".mp4",
                  web_dir="//%s/ddd/" % host,
                  filter_word="QR-1024")
    }
    try:
        detail['movies'].sort(reverse=True)
        detail['title'] = os.path.basename(detail['movies'][0])
    except:
        detail['title'] = u"未找到文件名"

    return render_template('detail.html', detail=detail)
Example #2
0
def scan_local_path():
    path_list = os.listdir(RESOURCE_PATH)
    for path in path_list:
        all_path = os.path.join(RESOURCE_PATH, path)
        if os.path.isdir(all_path):
            detail_path = path
            photo_list = find_file(path, ".jpg")
            movie_list = find_file(path, ".mp4")
            try:
                photo_path = os.path.basename(photo_list[0])
            except:
                photo_path = ""

            try:
                movie_list.sort(reverse=True)
                movie_name = movie_list[0].split("/")[1]
            except:
                movie_name = u"未找到影片名称"

            inset_db_from_local(movie_name, detail_path, photo_path)

    return ""
Example #3
0
        print path

        if os.path.isdir(all_path):
            detail_path = path
            photo_list = find_file_keys(os.path.join(RESOURCE_PATH, path),
                                        PHOTO_FORMANT)
            movie_list = find_file_keys(os.path.join(RESOURCE_PATH, path),
                                        MOVIE_FORMANT)
            try:
                # 这个是给首页展示图片的url里面的文件路径 就是ddd/0000/filename.jpg filename.jpg那一部分,可以带目录,但要用/
                photo_path = photo_list[0].replace('\\', '/')
            except:
                photo_path = ""

            try:
                movie_list.sort(reverse=True)
                movie_name = os.path.basename(movie_list[0])
                try:
                    movie_name = str_coding(movie_name)
                except:
                    pass
            except Exception as e:
                movie_name = u"未找到影片名称"
            inset_db_from_local(movie_name, detail_path, photo_path)
    return ""


if __name__ == '__main__':
    photo_list = find_file("J:\ddd\web_scan\94642251", ".jpg")
    photo_list += find_file("J:\ddd\web_scan\94642251", ".JPG")
    print photo_list