commandline-upload.rst 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. .. MediaGoblin Documentation
  2. Written in 2011, 2012 by MediaGoblin contributors
  3. To the extent possible under law, the author(s) have dedicated all
  4. copyright and related and neighboring rights to this software to
  5. the public domain worldwide. This software is distributed without
  6. any warranty.
  7. You should have received a copy of the CC0 Public Domain
  8. Dedication along with this software. If not, see
  9. <http://creativecommons.org/publicdomain/zero/1.0/>.
  10. ======================
  11. Command-line uploading
  12. ======================
  13. If you're a site administrator and have access to the server then you
  14. can use the 'addmedia' task. If you're just a user and want to upload
  15. media by the command line you can. This can be done with the pump.io
  16. API. There is `p <https://github.com/xray7224/p/>`_, which will allow you
  17. to easily upload media from the command line, follow p's docs to do that.
  18. To use the addmedia command::
  19. ./bin/gmg addmedia username your_media.jpg
  20. This will submit the file "your_media.jpg" to be a media entry
  21. associated with the user "username".
  22. You can get help on all the available options by running::
  23. ./bin/gmg addmedia --help
  24. Here's a longer example that makes use of more options::
  25. ./bin/gmg addmedia aveyah awesome_spaceship.png \
  26. --title "My awesome spaceship" \
  27. --description "Flying my awesome spaceship, since I'm an awesome pilot" \
  28. --license "http://creativecommons.org/licenses/by-sa/3.0/" \
  29. --tags "spaceships, pilots, awesome" \
  30. --slug "awesome-spaceship"
  31. You can also pass in the `--celery` option if you would prefer that
  32. your media be passed over to celery to be processed rather than be
  33. processed immediately.
  34. ============================
  35. Command-line batch uploading
  36. ============================
  37. There's another way to submit media, and it can be much more powerful, although
  38. it is a bit more complex.
  39. ./bin/gmg batchaddmedia admin /path/to/your/metadata.csv
  40. This is an example of what a script may look like. The important part here is
  41. that you have to create the 'metadata.csv' file.::
  42. media:location,dcterms:title,dcterms:creator,dcterms:type
  43. "http://www.example.net/path/to/nap.png","Goblin taking a nap",,"Image"
  44. "http://www.example.net/path/to/snore.ogg","Goblin Snoring","Me","Audio"
  45. The above is an example of a very simple metadata.csv file. The batchaddmedia
  46. script would read this and attempt to upload only two pieces of media, and would
  47. be able to automatically name them appropriately.
  48. The csv file
  49. ============
  50. The location column
  51. -------------------
  52. The location column is the one column that is absolutely necessary for
  53. uploading your media. This gives a path to each piece of media you upload. This
  54. can either a path to a local file or a direct link to remote media (with the
  55. link in http format). As you can see in the example above the (fake) media was
  56. stored remotely on "www.example.net".
  57. Other internal nodes
  58. --------------------
  59. There are other columns which can be used by the script to provide information.
  60. These are not stored as part of the media's metadata. You can use these columns to
  61. provide default information for your media entry, but as you'll see below, it's
  62. just as easy to provide this information through the correct metadata columns.
  63. - **id** is used to identify the media entry to the user in case of an error in the batchaddmedia script.
  64. - **license** is used to set a license for your piece a media for mediagoblin's use. This must be a URI.
  65. - **title** will set the title displayed to mediagoblin users.
  66. - **description** will set a description of your media.
  67. Metadata columns
  68. ----------------
  69. Other columns can be used to provide detailed metadata about each media entry.
  70. Our metadata system accepts any information provided for in the
  71. `RDFa Core Initial Context`_, and the batchupload script recognizes all of the
  72. resources provided within it.
  73. .. _RDFa Core Initial Context: http://www.w3.org/2011/rdfa-context/rdfa-1.1
  74. The uploader may include the metadata for each piece of media, or
  75. leave them blank if they want to. A few columns from `Dublin Core`_ are
  76. notable because the batchaddmedia script also uses them to set the default
  77. information of uploaded media entries.
  78. .. _Dublin Core: http://wiki.dublincore.org/index.php/User_Guide
  79. - **dc:title** sets a title for your media entry.
  80. - **dc:description** sets a description of your media entry.
  81. If both a metadata column and an internal node for the title are provided, mediagoblin
  82. will use the internal node as the media entry's display name. This makes it so
  83. that if you want to display a piece of media with a different title
  84. than the one provided in its metadata, you can just provide different data for
  85. the 'dc:title' and 'title' columns. The same is true of the 'description' and
  86. 'dc:description'.