Browse Source

Can now upload artwork on tracks

pull/194/head
squeaky otter 1 year ago
parent
commit
df5bf183c9
Signed by: dashie GPG Key ID: C2D57B325840B755
9 changed files with 29 additions and 19 deletions
  1. +1
    -3
      .gitignore
  2. +2
    -2
      api/app.py
  3. +3
    -1
      api/config/production_secret_sample.py
  4. +1
    -1
      api/controllers/api/tracks.py
  5. +3
    -1
      api/datas_helpers.py
  6. +6
    -4
      api/models.py
  7. +9
    -1
      front/src/services/api/api.service.js
  8. +4
    -6
      front/src/views/tracks/Upload.vue
  9. +0
    -0
      uploads/artwork_sounds/.gitkeep

+ 1
- 3
.gitignore View File

@ -2,9 +2,7 @@
/config.py
/.idea
*.db
/uploads/pictures/*
/uploads/sounds/*
/uploads/waveforms/
/uploads/*/*
/tmp/cty.xml
/.pytest_cache/
/api/reel2bits.egg-info


+ 2
- 2
api/app.py View File

@ -252,11 +252,11 @@ def create_app(config_filename="config.development.Config", app_name=None, regis
configure_uploads(app, sounds)
# Album artwork upload set
artworkalbums = UploadSet("artworkalbums", (".jpg", ".jpe", ".jpeg", ".png", ".gif"))
artworkalbums = UploadSet("artworkalbums", tuple("jpg jpe jpeg png gif JPG JPE JPEG PNG GIF".split()))
configure_uploads(app, artworkalbums)
# Track artwork upload set
artworksounds = UploadSet("artworksounds", (".jpg", ".jpe", ".jpeg", ".png", ".gif"))
artworksounds = UploadSet("artworksounds", tuple("jpg jpe jpeg png gif JPG JPE JPEG PNG GIF".split()))
configure_uploads(app, artworksounds)
# Total max size upload for the whole app


+ 3
- 1
api/config/production_secret_sample.py View File

@ -13,9 +13,11 @@ class Config(BaseConfig):
# Set your DB URI
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://dashie@localhost/reel2bits"
# Don't forget that SOUNDS and WAVEFORMS have to be under DEFAULT path folder
# Don't forget that SOUNDS and ARTWORKS, etc. have to be under DEFAULT path folder
UPLOADS_DEFAULT_DEST = "/Users/dashie/dev/reel2bits/uploads"
UPLOADED_SOUNDS_DEST = "/Users/dashie/dev/reel2bits/uploads/sounds"
UPLOADED_ARTWORKALBUMS_DEST = "/Users/dashie/dev/reel2bits/uploads/artwork_albums"
UPLOADED_ARTWORKSOUNDS_DEST = "/Users/dashie/dev/reel2bits/uploads/artwork_sounds"
# Where is the audiowaveform binary located
AUDIOWAVEFORM_BIN = "/usr/local/bin/audiowaveform"


+ 1
- 1
api/controllers/api/tracks.py View File

@ -15,7 +15,7 @@ from sqlalchemy import and_
bp_api_tracks = Blueprint("bp_api_tracks", __name__)
sounds = UploadSet("sounds", AUDIO)
artworksounds = UploadSet("artworksounds", (".jpg", ".jpe", ".jpeg", ".png", ".gif"))
artworksounds = UploadSet("artworksounds", tuple("jpg jpe jpeg png gif JPG JPE JPEG PNG GIF".split()))
@bp_api_tracks.route("/api/tracks", methods=["POST"])


+ 3
- 1
api/datas_helpers.py View File

@ -78,6 +78,8 @@ def to_json_track(track, account):
si = track.sound_infos.first()
url_orig = url_for("get_uploads_stuff", thing="sounds", stuff=track.path_sound(orig=True), _external=False)
url_transcode = url_for("get_uploads_stuff", thing="sounds", stuff=track.path_sound(orig=False), _external=False)
url_artwork = url_for("get_uploads_stuff", thing="artwork_sounds", stuff=track.path_artwork(), _external=False)
obj = {
"id": track.flake_id,
"uri": None,
@ -110,7 +112,7 @@ def to_json_track(track, account):
"slug": track.slug,
"local": track.user.actor[0].is_local(),
"title": track.title,
"picture_url": None, # FIXME not implemented yet
"picture_url": url_artwork,
"media_orig": url_orig,
"media_transcoded": url_transcode,
"waveform": (json.loads(si.waveform) if si else None),


+ 6
- 4
api/models.py View File

@ -337,16 +337,18 @@ class Sound(db.Model):
el = datetime.datetime.utcnow() - self.uploaded
return el.total_seconds()
def path_waveform(self):
fname, _ = os.path.splitext(self.filename)
return os.path.join(self.user.slug, "{0}.png".format(fname))
def path_sound(self, orig=False):
if self.transcode_needed and self.transcode_state == self.TRANSCODE_DONE and not orig:
return os.path.join(self.user.slug, self.filename_transcoded)
else:
return os.path.join(self.user.slug, self.filename)
def path_artwork(self):
if self.artwork_filename:
return os.path.join(self.user.slug, self.artwork_filename)
else:
return None
def licence_info(self):
return Reel2bitsDefaults.known_licences[self.licence]


+ 9
- 1
front/src/services/api/api.service.js View File

@ -151,7 +151,15 @@ const trackUpload = (trackInfo, store) => {
form.append('tags', trackInfo.tags.map(a => a.text))
// let the files last for dev tools inspection
if (trackInfo.artwork) {
form.append('artwork', trackInfo.artwork)
let filename = 'blob.invalid'
if (trackInfo.artwork.type === 'image/jpeg') {
filename = 'blob.jpg'
} else if (trackInfo.artwork.type === 'image/png') {
filename = 'blob.png'
} else if (trackInfo.artwork.type === 'image/gif') {
filename = 'blob.gif'
}
form.append('artwork', trackInfo.artwork, filename)
}
form.append('file', trackInfo.file)


+ 4
- 6
front/src/views/tracks/Upload.vue View File

@ -100,7 +100,7 @@
<div class="row">
<div class="col-sm-6">
<p v-translate translate-context="Content/TrackUpload/Text/Artwork picker" class="visibility-notice">
The recommended minimum size for artworks pictures is 112x112 pixels.
The recommended minimum size for artworks pictures is 112x112 pixels. JPEG, PNG or GIF only.
</p>
<p v-translate translate-context="Content/TrackUpload/Title/Artwork picker">
Current artwork
@ -119,12 +119,10 @@
<b-button
v-show="pickArtworkBtnVisible"
id="pick-artwork"
v-translate
class="btn"
type="button"
translate-context="Content/TrackUpload/Text/Artwork picker"
>
Upload an image
<translate translate-context="Content/TrackUpload/Button/Artwork picker">
Upload an image
</translate>
</b-button>
<image-cropper


+ 0
- 0
uploads/artwork_sounds/.gitkeep View File


Loading…
Cancel
Save